You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Max Grigoriev <da...@mail.ru> on 2003/11/27 15:07:40 UTC

Detach and Redirect Questions

Hello Tapestry Users,

We have 2 web systems, one is CMS site made on xsl and feedback site
made on Tapestry. In some situation I have to redirect from tapestry
page to external url. I can do it such way:
getRequestCycle().getRequestContext().getResponse().sendRedirect("external url");

But i think in this case current tapestry page will not be detached,
am i right ? If i'm right, how can i send right redirect ?

And throw new PageRedirectException(pageName) will not send client
redirect, it sends forward redirect. Is there way to send client
redirect to tapestry page ?

Thanks'
  

-- 
Best regards,
 Max                          mailto:darkit@mail.ru


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


Re: Detach and Redirect Questions

Posted by Paul Ferraro <pm...@columbia.edu>.
Your right - and looking at my own code where this is used, I also use a 
String[] rather than an Object[] just for that reason.  I agree with you 
that the String[] cast inside PageService.java is inappropriate.  I'll 
enter a bug for this.

Paul Ferraro


Baldur Norddahl wrote:

> Paul Ferraro wrote:
>
>> Use RedirectException(String url) to send client redirects.  If you 
>> need to generate a Tapestry URL, you can do so using:
>> requestCycle.getEngine().getService(Tapestery.PAGE_SERVICE).getLink(requestCycle, 
>> requestCycle.getPage(), new Object[] { "MyPage" }).getURL();
>>
>
> I tried that code, and you get an class cast exception because 
> PageService.java tries to cast the Object[] to String[].
>
> Somehow that seems to be either wrong or poorly documented. I had to 
> look at the source code to find out why I was getting that exception.
>
> Baldur
>
> ---------------------------------------------------------------------
> 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: Detach and Redirect Questions

Posted by Baldur Norddahl <bb...@clansoft.dk>.
Paul Ferraro wrote:

> Use RedirectException(String url) to send client redirects.  If you 
> need to generate a Tapestry URL, you can do so using:
> requestCycle.getEngine().getService(Tapestery.PAGE_SERVICE).getLink(requestCycle, 
> requestCycle.getPage(), new Object[] { "MyPage" }).getURL();
>

I tried that code, and you get an class cast exception because 
PageService.java tries to cast the Object[] to String[].

Somehow that seems to be either wrong or poorly documented. I had to 
look at the source code to find out why I was getting that exception.

Baldur


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


Re: Detach and Redirect Questions

Posted by Paul Ferraro <pm...@columbia.edu>.
Max Grigoriev wrote:

>Hello Tapestry Users,
>
>We have 2 web systems, one is CMS site made on xsl and feedback site
>made on Tapestry. In some situation I have to redirect from tapestry
>page to external url. I can do it such way:
>getRequestCycle().getRequestContext().getResponse().sendRedirect("external url");
>  
>
For more elegant handling, try throwing RedirectException(String url) - 
see detail below.

>But i think in this case current tapestry page will not be detached,
>am i right ? If i'm right, how can i send right redirect ?
>
>  
>
No - the current page will still detach.

>And throw new PageRedirectException(pageName) will not send client
>redirect, it sends forward redirect. Is there way to send client
>redirect to tapestry page ?
>
>Thanks'
>  
>
Use RedirectException(String url) to send client redirects.  If you need 
to generate a Tapestry URL, you can do so using:
requestCycle.getEngine().getService(Tapestery.PAGE_SERVICE).getLink(requestCycle, 
requestCycle.getPage(), new Object[] { "MyPage" }).getURL();

Similar urls can be generated using the external service if parameters 
need to be passed.

A bit ugly, I know.  Also, if you need to ensure that session identifier 
is propogated, don't forget to wrap your generated url with 
response.encodeRedirectURL();

Paul Ferraro

>  
>
>  
>



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