jQuery in Action, 2nd edition
The moose likes JSF and the fly likes Facelets: Clicking on a command link is displaying the URL of the previous request that was sent Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Facelets: Clicking on a command link is displaying the URL of the previous request that was sent" Watch "Facelets: Clicking on a command link is displaying the URL of the previous request that was sent" New topic
Author

Facelets: Clicking on a command link is displaying the URL of the previous request that was sent

Praison Selvaraj
Ranch Hand

Joined: Jun 05, 2010
Posts: 46
Hi All,

This is the scenario:

A facelet has a command link (part of a menu bar). When this link is clicked the URL in the address bar is not changing to the URL that is being requested. It is displaying the URL that was requested previously.

Clicking on the same link again changes the URL to what is being requested now.

The idea is to use the URL in a filter to perform authorization. As the URL is not the current one, this will lead to inconsistent results.

What needs to be done to ensure that the current URL gets displayed in the address bar (and not the previous one)?

Thanks,


SCJP, SCWCD, SCEA
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14480
    
    7

That is the current URL. However, JSF is primarily based on form postbacks. The URL is more in the nature of a session handle than it is a page locator the way it is in most web frameworks.

To update the URL to indicate the name of the current View, use the "redirect" option on your page navigation. In faces-config, it's just a simple element in the navigation ruleset with no body or attributes like so: <redirect/>

Observe caution, however. It takes more than just this if you expect to produce URLs that can be bookmarked!


Customer surveys are for companies who didn't pay proper attention to begin with.
Praison Selvaraj
Ranch Hand

Joined: Jun 05, 2010
Posts: 46
Thank you, Tim.

One question I have is, will the redirect mean that a redirect request will be sent to the browser?

If that is the case, then it would become an overhead....

Cheers,
Praison
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Facelets: Clicking on a command link is displaying the URL of the previous request that was sent
 
Similar Threads
displaying javascript in adress bar
HTTP status 404
Encoding, decoding problem
Tomcat 7 authentication error only with IE8 or IE7
using forwarded url