-1

I am developing a Web App using JSF 2.0 and I have developed a Navigation panel which user will have to use for navigating through the pages. The panel is woking fine. But at the same time I do not want user to use "Back","Forward" of the browser for the navigation. My idea is to if user hits any one those button I'll invalidate the session and show him a info page. Not sure how to aschieve this in JSF 2.0 , JavaScript is a option but I wonder whether JSF has any API support for this???

user1220373
  • 383
  • 1
  • 9
  • 19
  • 1
    Open it in a new window. Otherwise, you will severely anger the user. – Chad Hedgcock Mar 16 '12 at 06:13
  • You're going completely the wrong path to solve the problem. See also [Prevent user from going back to the previous secured page after logout](http://stackoverflow.com/questions/4194207/prevent-user-from-going-back-to-the-previous-secured-page-after-logout) – BalusC Mar 16 '12 at 11:25

1 Answers1

6

Don't prohibit the user from using the controls with which they are familiar. First, it presents many technical challenges, but more importantly, it deviates from very, very common paradigms that users expect.

It's acceptable to manipulate the browser history in some cases, and in very select cases it is acceptable to prompt the user before leaving a screen (such as a business application where work might be lost when the user navigates).

It might be appropriate to perform a check with JavaScript prior to leaving the page if the user risks losing significant work. You could then prompt the user, and if they elect to navigate, your server code could check the referring URL and determine from a parameter what flow the user had taken.

Regarding specific technology; checking a query string variable is easy with nearly any server technology (and JavaScript with or without jQuery will work for any client-side logic).

Again, avoid this unless there is no other alternative.

This discussion has information on disabling the back button (why it is not a good idea, and possible alternatives and options).

Community
  • 1
  • 1
Tim M.
  • 53,671
  • 14
  • 120
  • 163
  • But there are some logic which are executed when user uses the navigation buttons in the Nagivation panel. Those will not be executed in that case and which may compromise some UI logic. – user1220373 Mar 16 '12 at 09:26