You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by kranga <kr...@k2d2.org> on 2005/01/12 02:26:28 UTC

Page redirecting on client side

I thought throwing a PageRedirectException() will cause  a client-side
redirect. Is that true? I'm not seeing that. If not, how do I do a
client-side URL to a valid Tapestry page using the target page's name?

Thanks


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


Re: Page redirecting on client side

Posted by kranga <kr...@k2d2.org>.
Thanks - should be simple to introduce a helper method into my page base
class. I tried using the ExternalPage service, but then I'd be forced to
make everything an external class. This is a better solution. I didn't want
my entire application to refer to the login URL!!!

----- Original Message ----- 
From: "Paul Ferraro" <pm...@columbia.edu>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, January 11, 2005 9:00 PM
Subject: Re: Page redirecting on client side


> Throwing PageRedirectException sure seems to be throwing a lot of
> confusion...
> PageRedirectException is caught in AbstractEngine.service().  When
> caught, it performs a requestCycle.activate() on the specified page,
> discards any existing output, and then renders that page.
> To perform a client-side redirect, you need to throw a
> RedirectException.  Since RedirectException is constructed with a full
> URL, you'll need to generate the appropriate Tapestry URL manually.
>
> e.g. To perform a redirect to a page:
>
> String page = // Page to which I'd like to redirect
> String url =
>
requestCycle.getEngine().getService(Tapestry.PAGE_SERVICE).getLink(requestCy
cle,
> requestCycle.getPage(), new String[] { page }).getURL();
> throw new RedirectException(url);
>
> This is an area that I hope to streamline in 3.1.
>
> Paul
>
> kranga wrote:
>
> >I thought throwing a PageRedirectException() will cause  a client-side
> >redirect. Is that true? I'm not seeing that. If not, how do I do a
> >client-side URL to a valid Tapestry page using the target page's name?
> >
> >Thanks
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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


Re: Page redirecting on client side

Posted by Paul Ferraro <pm...@columbia.edu>.
Throwing PageRedirectException sure seems to be throwing a lot of 
confusion...
PageRedirectException is caught in AbstractEngine.service().  When 
caught, it performs a requestCycle.activate() on the specified page, 
discards any existing output, and then renders that page.
To perform a client-side redirect, you need to throw a 
RedirectException.  Since RedirectException is constructed with a full 
URL, you'll need to generate the appropriate Tapestry URL manually.

e.g. To perform a redirect to a page:

String page = // Page to which I'd like to redirect
String url = 
requestCycle.getEngine().getService(Tapestry.PAGE_SERVICE).getLink(requestCycle, 
requestCycle.getPage(), new String[] { page }).getURL();
throw new RedirectException(url);

This is an area that I hope to streamline in 3.1.

Paul

kranga wrote:

>I thought throwing a PageRedirectException() will cause  a client-side
>redirect. Is that true? I'm not seeing that. If not, how do I do a
>client-side URL to a valid Tapestry page using the target page's name?
>
>Thanks
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


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


Re: Page redirecting on client side

Posted by Jonathan Millett <jo...@millett.net>.
PageRedirectException just activates a new page internally within the 
current request cycle.
Try throwing a RedirectException instead.  Pass a url that starts with 
"/" or contains "://" to generate a temporary redirect (3xx) response to 
the browser.
You can generate the url using PageService.getLink() method.

For Example:
Object[] parameters = {"MyPage"};
throw new RedirectException(engine.getService("page").getLink(cycle, 
this, parameters).getAbsoluteURL());

Cheers,
Jon

kranga wrote:

>I thought throwing a PageRedirectException() will cause  a client-side
>redirect. Is that true? I'm not seeing that. If not, how do I do a
>client-side URL to a valid Tapestry page using the target page's name?
>
>Thanks
>