10 Replies Latest reply on Feb 4, 2008 5:05 AM by pnk087

    Problem : "view state could't be restored"

    mblondel

      Hello,

      I use a4j in a page with several <a4j:region> and I have the alert "view state could't be restored" which appears after 5 mins.
      I don't know why.
      Thanks for your help

        • 1. Re: Problem :
          ilya_shaikovsky

          This mean that session expired. You may prevent it by a4j:poll usage. Or handle it with onExpired function redefinition. Check dev guide for more details.

          • 2. Re: Problem :
            mblondel

            I use a4j:poll in my page.
            Where I have to redefine the function onExpired ?
            How can I restore the view state with this function ?

            Thanks

            • 3. Re: Problem :
              ilya_shaikovsky

              try to look here.

              There is a link to a chapter where client handlers described.

              • 4. Re: Problem :
                ilya_shaikovsky
                • 5. Re: Problem :
                  mblondel

                  I can redifine the js function A4J.AJAX.onExpired. thanks.
                  But I don't understand why the session has expired.

                  The session expires because of a timeout or something else ?
                  Can I set a param to disable the timeout ?

                  thanks

                  • 6. Re: Problem :
                    ilya_shaikovsky

                    You may look and change for the timeout value in your web.xml. Or use a4j:poll which will be generate a request once to the timeout time.

                    • 7. Re: Problem :
                      mblondel

                       

                      "Or use a4j:poll which will be generate a request once to the timeout time"


                      But if the session has expired, I can't send a request ?
                      And how can I restore the session ?



                      • 8. Re: Problem :
                        ilya_shaikovsky

                        Session will not be expired if the poll will periodically send a request. :)

                        to restore you may just reload page in you? handler or for example redirect the user to the main default page.

                        • 9. Re: Problem :
                          johnboardman

                          I was also getting view state could not be restored when my session had definitely NOT timed out. My timeouts are set at 30 minutes, and the view state issue would occur at any time. This was particularly problematic over slow connections (hitting servers in other countries, over VPN, etc). Here is how I solved nearly every case of the problem, although it still very rarely happens.

                          Add the following attributes to your a4j tags:
                          timeout="240000" (4 minutes, less may work - I put it this high purely from frustration)
                          requestDelay="250" (1/4 second, you may need to increase it - higher times = slower response times since it waits at least this long before submitting requests)

                          These added attributes worked for me. I hope they help you as well.

                          • 10. Re: Problem :
                            pnk087

                            Hi,
                            About redefine the onExpired method, where should I put this method? Could you show me?
                            Thanks
                            Khanh