Browser back issue
Hi.
I'm using session scoped beans and a refresh logic. Each link in menu has a actionListener that clears / refreshes a bean.
For example I have aItemSearch.faces andItemDetail.faces.
<h:commandLink action="ItemSearch" actionListener="#{ItemBean.clear}" value="Search Item" />
Page flow must be strict and I must ensure thatItemSearch.faces must be accessed from menu.
I must,
- Disable back using browsers back/forward buttons
- Disable directly typing url
any suggestions ?
If these are not possible, I must code clear/refresh login every link on every page. :S
thanks.
# 1
I have a wizard style application which requires the user to not use their browser back/forward buttons.
I can tell you that this is tricky. You can disable the browser buttons with JavaScript, but that still doesn't mean the user can't use back and forward (user could always disable JavaScript). So you're left with having to track user progress through the application.
Basically, all my navigation gets passed through a class that tracks the user. It records their current page, and determines the next page they should view. I also test to see if the current page they are on is the current page they should be on. If it isn't, I throw a nice error asking them not to use the browser buttons. They then click a link that "re-synchronizes" them with where they should be (i.e. I put them back on the page they should be on).
This works whether they type a URL in or use their browser buttons.
Hope this helps,
CowKing
# 2
I'am using the following technique:
In "every" response is included a randomly generated token (value of a <input type"hidden">. This token is saved in the session too. During request processing is checked if the request includes a parameter named token and his value matches the saved token. If not the user is shown an "error page" with a message. The app should better display the last view instead. I will implement this later.
Generating of the token and check are implemented in a PhaseListener.