1

I have an application that uses a viewScoped bean for jsf xhtml page. This page consists of two htmlPanelGroup components out of which only one gets rendered depending on an attribute's boolean value in the page bean. When the page loads it displays panelGroup1 for verification of a user input in inputText field. A command button submits the value to the pageBean. If verification succeeds then pageBean method sets a boolean value and returns null and reloads the same page however this time it renders panelGroup2. Now this panelGroup displays input fields and then a commandButton. This command button's action calls a method in pageBean which first validates the input and then if successful returns the next xhtml name with faces-redirect option set to true. enter image description here

The problem is that the next page is displayed but when I click on back button, the browser displays "Document Expired" page and asks to reload. If i reload the page, somehow the previous page again gets displayed with panelGroup2! I have used the filter to set the headers and no cache option but still it doesnt work. Ideally if it loads the previous page I would expect it to display it with panelGroup1. Not sure what is the issue here. Can anyone provide any inputs on this?

Yogender Singh
  • 291
  • 2
  • 3
  • 9
  • "Document Expired" will only appear if the previous request was a synchronous POST request. In other words, the `faces-redirect=true` didn't seem to work. Perhaps a typo or timing mistake? See also http://stackoverflow.com/questions/28123085/clicking-browser-back-button-after-jsf-navigation-causes-document-expired-in-b – BalusC Jan 26 '15 at 14:55
  • in the action method of pageBean i am returning this return "ConfirmRegistration.xhtml?faces-redirect=true"; – Yogender Singh Jan 26 '15 at 15:00
  • And I am using a commandButton to first submit a form and then redirect to another page using the above return statement. Am i following the Post-Redirect-Get here? or is it something else? – Yogender Singh Jan 26 '15 at 15:06
  • Then apparently the form is itself using synchronous POST requests instead of ajax requests to perform validation and conditionally render content. – BalusC Jan 26 '15 at 15:10
  • using jsf2.2 Mojarra2.2.0. Is it the default behavior? One thing to note is that refresh doesnt resubmit the previous form again. – Yogender Singh Jan 26 '15 at 15:32
  • 1
    Whether a form submit uses ajax or not doesn't depend on JSF impl/version. It depends on your own coding. – BalusC Jan 26 '15 at 15:37

0 Answers0