You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/08/15 10:12:59 UTC

t5: forwarding page but no change in the url?

Hi,

I'm trying to some url rewriting in the Index.java:

I have this:
http://mydomain.com/item/123

which displays item 123, now if user type url:http://mydomain.com/123, I'll
forward it in onActivate to /item/123 as follows:

Object onActivate(Object[] obj) {
      if (obj.length > 0) {
          String code = (String) obj[0];
         	return
resources.createPageLink(Utils.getClassBaseName(Item.class.getName()), true,
code);
      } else
      	return Home.class;
  }


This works well, however, a little problem:

when user type: http://mydomain.com/123
url displayed in the browser is http://mydomain.com/item/123

is there a way to just keep it like http://mydomain.com/123 in the browser?

Thanks,

Angelo
-- 
View this message in context: http://www.nabble.com/t5%3A-forwarding-page-but-no-change-in-the-url--tp18995306p18995306.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: t5: forwarding page but no change in the url?

Posted by Angelo Chen <an...@yahoo.com.hk>.
no until you told me:) that's good idea too, so either a component or part of
index page are the options that i can try, instead of forwarding which seems
not working in filter type like t5 apps.

Thanks,

Angelo



Jonathan Barker wrote:
> 
> 
> Have you considered making your "Item" page an Item component, and then
> rendering that as a part of your Index page?
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-forwarding-page-but-no-change-in-the-url--tp18995306p19007566.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: t5: forwarding page but no change in the url?

Posted by Jonathan Barker <jo...@gmail.com>.
Have you considered making your "Item" page an Item component, and then
rendering that as a part of your Index page?


> -----Original Message-----
> From: Angelo Chen [mailto:angelochen960@yahoo.com.hk]
> Sent: Friday, August 15, 2008 04:13
> To: users@tapestry.apache.org
> Subject: t5: forwarding page but no change in the url?
> 
> 
> Hi,
> 
> I'm trying to some url rewriting in the Index.java:
> 
> I have this:
> http://mydomain.com/item/123
> 
> which displays item 123, now if user type url:http://mydomain.com/123,
> I'll
> forward it in onActivate to /item/123 as follows:
> 
> Object onActivate(Object[] obj) {
>       if (obj.length > 0) {
>           String code = (String) obj[0];
>          	return
> resources.createPageLink(Utils.getClassBaseName(Item.class.getName()),
> true,
> code);
>       } else
>       	return Home.class;
>   }
> 
> 
> This works well, however, a little problem:
> 
> when user type: http://mydomain.com/123
> url displayed in the browser is http://mydomain.com/item/123
> 
> is there a way to just keep it like http://mydomain.com/123 in the
> browser?
> 
> Thanks,
> 
> Angelo
> --
> View this message in context: http://www.nabble.com/t5%3A-forwarding-page-
> but-no-change-in-the-url--tp18995306p18995306.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by Andy Huhn <am...@hslt-online.com>.
Hi Angelo,

You can accomplish this by using Delegates.  Put a Delegate on your
index page, and in your Index.java, put a getter for that delegate.  The
delegate may return a block from one of any number of other pages.

See http://wiki.apache.org/tapestry/Tapestry5HowToCreateATabPanel .

Andy

On Fri, 2008-08-15 at 01:12 -0700, Angelo Chen wrote:
> Hi,
> 
> I'm trying to some url rewriting in the Index.java:
> 
> I have this:
> http://mydomain.com/item/123
> 
> which displays item 123, now if user type url:http://mydomain.com/123, I'll
> forward it in onActivate to /item/123 as follows:
> 
> Object onActivate(Object[] obj) {
>       if (obj.length > 0) {
>           String code = (String) obj[0];
>          	return
> resources.createPageLink(Utils.getClassBaseName(Item.class.getName()), true,
> code);
>       } else
>       	return Home.class;
>   }
> 
> 
> This works well, however, a little problem:
> 
> when user type: http://mydomain.com/123
> url displayed in the browser is http://mydomain.com/item/123
> 
> is there a way to just keep it like http://mydomain.com/123 in the browser?
> 
> Thanks,
> 
> Angelo



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by Angelo Chen <an...@yahoo.com.hk>.
well, a good direction, will give this a try, thanks.


Filip S. Adamsen-2 wrote:
> 
> Pretty much. Of course that might not work for you, it was merely a 
> suggestion.
> 
> -Filip
> 
> On 2008-08-16 02:28, Angelo Chen wrote:
>> you meant the Item page should be merged into the Index page?
>> 
>> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-forwarding-page-but-no-change-in-the-url--tp18995306p19007556.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Pretty much. Of course that might not work for you, it was merely a 
suggestion.

-Filip

On 2008-08-16 02:28, Angelo Chen wrote:
> you meant the Item page should be merged into the Index page?
> 
> 
> Filip S. Adamsen-2 wrote:
>> But it's still a page that you could use instead of your current Index 
>> page...
>>
>> -Filip
>>
>> On 2008-08-16 01:42, Angelo Chen wrote:
>>> hi,
>>>
>>> the Item page is quite complicated, one idea might be: render the page in
>>> the Index page and return it as StreamResponse, then the question is, is
>>> it
>>> possible to render a page in code and return that as Stream?
>>>
>>> Angelo
>>>
>>>
>>>
>>> But instead of redirecting in onActivate, why don't you get the item id 
>>> and do what your ItemIndex page does on the Index page?
>>>
>>> -Filip
>>>
>>> On 2008-08-15 17:09, Angelo Chen wrote:
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by Angelo Chen <an...@yahoo.com.hk>.
you meant the Item page should be merged into the Index page?


Filip S. Adamsen-2 wrote:
> 
> But it's still a page that you could use instead of your current Index 
> page...
> 
> -Filip
> 
> On 2008-08-16 01:42, Angelo Chen wrote:
>> hi,
>> 
>> the Item page is quite complicated, one idea might be: render the page in
>> the Index page and return it as StreamResponse, then the question is, is
>> it
>> possible to render a page in code and return that as Stream?
>> 
>> Angelo
>> 
>> 
>> 
>> But instead of redirecting in onActivate, why don't you get the item id 
>> and do what your ItemIndex page does on the Index page?
>> 
>> -Filip
>> 
>> On 2008-08-15 17:09, Angelo Chen wrote:
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-forwarding-page-but-no-change-in-the-url--tp18995306p19007424.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
But it's still a page that you could use instead of your current Index 
page...

-Filip

On 2008-08-16 01:42, Angelo Chen wrote:
> hi,
> 
> the Item page is quite complicated, one idea might be: render the page in
> the Index page and return it as StreamResponse, then the question is, is it
> possible to render a page in code and return that as Stream?
> 
> Angelo
> 
> 
> 
> But instead of redirecting in onActivate, why don't you get the item id 
> and do what your ItemIndex page does on the Index page?
> 
> -Filip
> 
> On 2008-08-15 17:09, Angelo Chen wrote:
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by Angelo Chen <an...@yahoo.com.hk>.
hi,

the Item page is quite complicated, one idea might be: render the page in
the Index page and return it as StreamResponse, then the question is, is it
possible to render a page in code and return that as Stream?

Angelo



But instead of redirecting in onActivate, why don't you get the item id 
and do what your ItemIndex page does on the Index page?

-Filip

On 2008-08-15 17:09, Angelo Chen wrote:

-- 
View this message in context: http://www.nabble.com/t5%3A-forwarding-page-but-no-change-in-the-url--tp18995306p19007092.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
But instead of redirecting in onActivate, why don't you get the item id 
and do what your ItemIndex page does on the Index page?

-Filip

On 2008-08-15 17:09, Angelo Chen wrote:
> Hi Filip,
> 
> yes, I'm using Index page,  the only issue is, when you return the correct
> page in the onActivate, the URL in the browser got changed. how to do this
> in index page? something like a servlet forward?
> 
> 
> Filip S. Adamsen-2 wrote:
>> That is, as far as I know, not possible.
>>
>> But if you really need to have URLs that look like that, why not use the 
>> Index page for it? That should do exactly what you want...
>>
>> -Filip
>>
>> On 2008-08-15 10:12, Angelo Chen wrote:
>>> Hi,
>>>
>>> I'm trying to some url rewriting in the Index.java:
>>>
>>> I have this:
>>> http://mydomain.com/item/123
>>>
>>> which displays item 123, now if user type url:http://mydomain.com/123,
>>> I'll
>>> forward it in onActivate to /item/123 as follows:
>>>
>>> Object onActivate(Object[] obj) {
>>>       if (obj.length > 0) {
>>>           String code = (String) obj[0];
>>>          	return
>>> resources.createPageLink(Utils.getClassBaseName(Item.class.getName()),
>>> true,
>>> code);
>>>       } else
>>>       	return Home.class;
>>>   }
>>>
>>>
>>> This works well, however, a little problem:
>>>
>>> when user type: http://mydomain.com/123
>>> url displayed in the browser is http://mydomain.com/item/123
>>>
>>> is there a way to just keep it like http://mydomain.com/123 in the
>>> browser?
>>>
>>> Thanks,
>>>
>>> Angelo
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Filip,

yes, I'm using Index page,  the only issue is, when you return the correct
page in the onActivate, the URL in the browser got changed. how to do this
in index page? something like a servlet forward?


Filip S. Adamsen-2 wrote:
> 
> That is, as far as I know, not possible.
> 
> But if you really need to have URLs that look like that, why not use the 
> Index page for it? That should do exactly what you want...
> 
> -Filip
> 
> On 2008-08-15 10:12, Angelo Chen wrote:
>> Hi,
>> 
>> I'm trying to some url rewriting in the Index.java:
>> 
>> I have this:
>> http://mydomain.com/item/123
>> 
>> which displays item 123, now if user type url:http://mydomain.com/123,
>> I'll
>> forward it in onActivate to /item/123 as follows:
>> 
>> Object onActivate(Object[] obj) {
>>       if (obj.length > 0) {
>>           String code = (String) obj[0];
>>          	return
>> resources.createPageLink(Utils.getClassBaseName(Item.class.getName()),
>> true,
>> code);
>>       } else
>>       	return Home.class;
>>   }
>> 
>> 
>> This works well, however, a little problem:
>> 
>> when user type: http://mydomain.com/123
>> url displayed in the browser is http://mydomain.com/item/123
>> 
>> is there a way to just keep it like http://mydomain.com/123 in the
>> browser?
>> 
>> Thanks,
>> 
>> Angelo
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/t5%3A-forwarding-page-but-no-change-in-the-url--tp18995306p19000288.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: forwarding page but no change in the url?

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
That is, as far as I know, not possible.

But if you really need to have URLs that look like that, why not use the 
Index page for it? That should do exactly what you want...

-Filip

On 2008-08-15 10:12, Angelo Chen wrote:
> Hi,
> 
> I'm trying to some url rewriting in the Index.java:
> 
> I have this:
> http://mydomain.com/item/123
> 
> which displays item 123, now if user type url:http://mydomain.com/123, I'll
> forward it in onActivate to /item/123 as follows:
> 
> Object onActivate(Object[] obj) {
>       if (obj.length > 0) {
>           String code = (String) obj[0];
>          	return
> resources.createPageLink(Utils.getClassBaseName(Item.class.getName()), true,
> code);
>       } else
>       	return Home.class;
>   }
> 
> 
> This works well, however, a little problem:
> 
> when user type: http://mydomain.com/123
> url displayed in the browser is http://mydomain.com/item/123
> 
> is there a way to just keep it like http://mydomain.com/123 in the browser?
> 
> Thanks,
> 
> Angelo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org