Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Praison Selvaraj
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Praison Selvaraj
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!