You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Dean Hiller <de...@xsoftware.biz> on 2006/03/21 14:59:33 UTC

disable back button?

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)
thanks,
dean


Re: disable back button?

Posted by Enrique Medina <e....@gmail.com>.
This is a recurrent problem. There are several possible solutions:

1) Use request-scoped beans combined with <t:saveState>
2) Use session-scoped beans with "Redirect-after-post" pattern (basically
doing redirects in all your navigation)

Search within this forum for these topics and you'll find lots of threads
discussing about this problem.

Regards,
Enrique Medina.

On 3/21/06, Dean Hiller <de...@xsoftware.biz> wrote:
>
> 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)
> thanks,
> dean
>
>

Re: disable back button?

Posted by Aleksei Valikov <va...@gmx.net>.
Hi.

> 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.

Bye.
/lexi