2009/1/18 bansi <mail2ba...@yahoo.com>:
>
> Thanks for quick responses.
> If i correctly understand you are referring to <redirect/> in
> faces-navigation.xml file , which is the outcome of an action method.  I
> have been using this technique for navigation or redirect on returning error
> message from action methods. But unable to understand how will this help in
> bookmarking JSF pages.
>
> For example i want to bookmark JSF page from search results always get
> appended with JSessionId
> like:
>
> http://localhost:8080/namsNG/login.faces;jsessionid=6DD6C3BE51CE502B0036E528BDB253FF
>
> And if i copy/paste this url into another browser instance it returns the
> Homepage instead of actual page

I'm not sure why your example doesn't work, but relying on a session
ID in a bookmark doesn't work very well, since sessions time out. Your
bookmark would be valid only for about 30 minutes, depending on your
session time out configuration.

<redirect /> helps in creating bookmarkable pages, because JSF uses a
postback for navigation.

For example, let's say you have a link on page "a.faces" that (in a
functional way) navigates to "b.faces".

When using forward (the default navigation style), the link triggers
(under the bonnet) a form submit to "a.faces". The navigation hander
of JSF then renders b.faces using a forward.
The result of this is that the url in your address bar in your browser
is always one page behind, since it shows "a.faces" while the rendered
page is "b.faces".

When using <redirect />, the link also posts to "a.faces", but now,
instead of forwarding to "b.faces", JSF returns a 302 (redirect)
response. This triggers the browser to load the "b.faces" using a new
request. Now, the url in the address bar of the browser matches the
rendered HTML.

What does this mean for bookmarking? Well, when using redirect, you
know you have bookmarked the correct url, instead of the one you
visited one request earlier.

But, again, don't rely on the session ID in your bookmarks. Better use
querystring parameters.

Regards,

/Jan-Kees

Reply via email to