I use Ajax4Jsf 1.1.4 (,tiles and i small part of struts) in my JSF application. When there is no user activity on the page for some minutes (15?) and then the user click on the Command link the ajax action isn�t done correctly because the Ajax4Jsf view root is lost.
A combo with the error message "View State couldn't be restored" is displayed and when the user confirms the message a normal request is done. This doesn�t occur because of a normal session timeout (the session timeout is much longer).
What is the reason for this behavoir? Is there something like a internal ajax4jsf (session) timeout? Must the context parameter <session-timeout> in the faces config.xml be declared? What can I do to fix this bug?
Here is a section of my web.xml, which might be interesting.
<context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> <description> State saving method: "client" or "server" (= default) See JSF Specification 2.5.2 </description> </context-param>
<context-param> <param-name> org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION </param-name> <param-value>3</param-value> <description> Only applicable if state saving method is "server" (= default). Defines the amount (default = 20) of the latest views are stored in session. </description> </context-param>
I can try to set the hard coded parameter in the web.xml and look if it work.
The session timeout I set is much larger than the "view root timeout". After the user has confirmed the error message a normal request is done (but not the supposed action of the original link) and than the user can continue working in his session.
Perhaps there is a internal timeout parameter or a memory problem or something else ... ?
This happens because of the StateManager implementation (AjaxStateManager) can't work with states on server - it simply returns null, when trying to restore session, because no mechanism for state saving is implemented there - you can see the code.
You can define another state manager in faces-config.xml, i.e. MyFaces one. He has well working state saving mechanism.
This can be done in the following manner:
This has a draw-back - in time View will also become expired, but the timeout can be configured. I don't remember how...