I faced the same problem. I did not find a 100% satisfactory solution. But look at this approach from BalusC . This solution will not save values if you press the return button of the browser without controlling the browser cache.
<h:form>
<h:inputText id="somefield" required="true" value="#{formbean.someProperty}"/>
<h:message for="somefield" />
<h:commandButton value="POST with redirect and ajax" action="third?faces-redirect=true">
<f:ajax execute="@form" render="@form" />
</h:commandButton>
</h:form>
Download the page, leave the field blank, publish the form (-> an error message appears), enter the data, publish it again and click the "Back" button. This will display the form again, the error message has disappeared, but the value of the input field has also disappeared.
, - formbeans ( , flash, view-params,...), , (GET-) "". :
JSF-:
<f:view>
<f:event type="preRenderView" listener="#{formbean.doNotCache}"/>
</f:view>
Bean:
public void doNotCache(ComponentSystemEvent event) {
Faces.getResponse().setHeader("Pragma", "no-cache");
Faces.getResponse().setHeader("Cache-Control", "no-cache");
Faces.getResponse().addHeader("Cache-Control", "must-revalidate");
Faces.getResponse().addHeader("Cache-Control", "no-store");
}
, . , , Post-Redirect-Get-Pattern. ( ) . (, , , / ?). , , , .