myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aleksei Valikov <>
Subject Re: disable back button?
Date Tue, 21 Mar 2006 14:21:44 GMT

> so I spent hours debugging something that was not my apps bug.  
> Basically I clicked a commandLink on my app.  I clicked IE back button 
> and clicked a different commandLink button(this resulted in refreshing 
> the page).  I then clicked the same commandLink and this time it went to 
> the page it was supposed to go to.  How can I resolve this issue?  This 
> obviously will be considered a bug by my users.
> Is there a way to fix this problem? 1. don't allow back button
> 2. get the commandlinks to work without having to refresh the page(I am 
> using tree2)

The problem is that when you go "back" in history, you're getting to the 
old application state. This state is no longer actual, so you can't do 
anything with it.
Your choices are:

1. Disable history navigation by excluding your pages from the cache. 
Done with headers:
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
This will force your pages to be reloaded when users go "back". 
Unfortunatelly, since JSF is primarily POST-method based, this method 
results in this ugly prompt window asking users if they really want to 
resubmit the POST request.

2. Diable the "back" button with javascript clearing the history in browser.

3. Use client-side state saving. Then, when users go back, they also go 
back to the old state (serialized on the client side).

I'm currently using the first choice. However, the "repost" prompt is 
really ugly. When I have time, I'll implement a tracking PhaseListener 
(memorizing user's path on the server) and a small javascript which 
hacks "prev" and "next" buttons in the browser.


View raw message