0

I have the following problem:
If the action of a CommandLink in the backing bean is executing and the user clicked the reload button or press F5 before the backing bean is completed, the result url of the backing bean is ignored and the current page is refreshed.
In the following very simple example the example.jsf is reloaded, but the nextPage.jsf is not called.

example.jsf

...  
<h:commandLink id="actionNext" action="#{bean.action}" />  
...  

bean.java

...  
fuction String action() {
    ...  
    return "nextPage"
}   

Is there a common solution for that problem?
Or has anybody an idea to prevent the reload useing JavaScript?
Thanks for help.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • That it is 'ignored' is to be expected and happens also when in plain html you click a normal link that would take you to another page and you press F5 in the mean time. Are you creating some 'wizard' like functionality? Maybe you should use ajax and only update parts of the page in the same xhtml file. Read https://stackoverflow.com/questions/7108668/how-to-ajax-refresh-dynamic-include-content-by-navigation-menu-jsf-spa and take/use the relevant parts from there. – Kukeltje Jul 16 '18 at 11:23
  • Thanks for your replay. I know that this is the expected behavior, but it is not very nice, because the business action is committed and the navigation to the next page is stopped. Thanks for the link. – Tim Hallwachs Jul 17 '18 at 05:50
  • It **is** nice, otherwise malicious sites could lock you into their pages.. Best solution is in the previous link, but also read https://stackoverflow.com/questions/821011/prevent-a-webpage-from-navigating-away-using-javascript – Kukeltje Jul 17 '18 at 06:53
  • Thanks, I will test it. – Tim Hallwachs Jul 17 '18 at 09:59

0 Answers0