You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jérôme BERNARD <je...@gmail.com> on 2005/04/15 19:01:26 UTC

Redirects...

Hi,

Why do the two lines below differ?
1) throw new RedirectException("affiliate/Home.html");
2) cycle.getRequestContext().getResponse().sendRedirect("affiliate/Home.html");

My app starts with Home.html (not affiliate/Home.html !!). When using
1), my app is redirected to Home.direct, whereas case 2) redirects me
to the proper page (affiliate/Home.html). I don't understand why...

Jérôme.

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


Re: Redirects...

Posted by Alberto Lepe <al...@gmail.com>.
try:

throw new PageRedirectException(getRequestCycle().getPage("Home"));	  

That worked for me.

On 4/15/05, Jérôme BERNARD <je...@gmail.com> wrote:
> Hi,
> 
> Why do the two lines below differ?
> 1) throw new RedirectException("affiliate/Home.html");
> 2) cycle.getRequestContext().getResponse().sendRedirect("affiliate/Home.html");
> 
> My app starts with Home.html (not affiliate/Home.html !!). When using
> 1), my app is redirected to Home.direct, whereas case 2) redirects me
> to the proper page (affiliate/Home.html). I don't understand why...
> 
> Jérôme.
> 
> ---------------------------------------------------------------------
> 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: Redirects...

Posted by Jérôme BERNARD <je...@gmail.com>.
I forgot to indicate that I'm using Picasso (4.0).

One possible way of doing it, based on your solution is:
throw new RedirectException(getPageService().getLink(cycle,
"affiliate/Home").getAbsoluteURL());

where your page is abstract and define the following abstract method:
public abstract IEngineService getPageService();

and your page definition contains:
<inject property="pageService" object="engine-service:page"/>

Thanks for your help,
Jérôme.

On 4/15/05, Paul Ferraro <pm...@columbia.edu> wrote:
> The RedirectException() will forward (i.e. server-side) the request if a
> relative uri is specified.  If the uri specified is absolute then it
> will perform a redirect (as in #2).
> When I need to redirect to a page, I perform the following:
> throw new
> RedirectException(cycle.getEngine().getService(Tapestry.PAGE_SERVICE).getLink(cycle,
> cycle.getPage(), new String[] { "MyPageName" }).getURL());
> 
> Paul
> 
> Jérôme BERNARD wrote:
> 
> >Hi,
> >
> >Why do the two lines below differ?
> >1) throw new RedirectException("affiliate/Home.html");
> >2) cycle.getRequestContext().getResponse().sendRedirect("affiliate/Home.html");
> >
> >My app starts with Home.html (not affiliate/Home.html !!). When using
> >1), my app is redirected to Home.direct, whereas case 2) redirects me
> >to the proper page (affiliate/Home.html). I don't understand why...
> >
> >Jérôme.
> >
> >---------------------------------------------------------------------
> >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: Redirects...

Posted by Paul Ferraro <pm...@columbia.edu>.
The RedirectException() will forward (i.e. server-side) the request if a 
relative uri is specified.  If the uri specified is absolute then it 
will perform a redirect (as in #2).
When I need to redirect to a page, I perform the following:
throw new 
RedirectException(cycle.getEngine().getService(Tapestry.PAGE_SERVICE).getLink(cycle, 
cycle.getPage(), new String[] { "MyPageName" }).getURL());

Paul

Jérôme BERNARD wrote:

>Hi,
>
>Why do the two lines below differ?
>1) throw new RedirectException("affiliate/Home.html");
>2) cycle.getRequestContext().getResponse().sendRedirect("affiliate/Home.html");
>
>My app starts with Home.html (not affiliate/Home.html !!). When using
>1), my app is redirected to Home.direct, whereas case 2) redirects me
>to the proper page (affiliate/Home.html). I don't understand why...
>
>Jérôme.
>
>---------------------------------------------------------------------
>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