4 Replies Latest reply on Mar 13, 2007 7:32 PM by ishabalov

    Session Expired Handling with Ajax4jsf

    kfletcher2005

      I have read from the documentation a cryptic example of how to handle http session expiration using ajax4jsf.

      Here is the only snippet from the documentation.....
      --------------------------------------------------------
      Beginning with Ajax4jsf version 1.0.5 it's possible to redefine also the "onExpired" framework method that is called on the "Session Expiration" event.

      A4J.AJAX.onExpired = function(loc,expiredMsg){

      // Custom Developer Code
      alert("Hey dude, the session expired");

      };

      Here the function receives in params:

      * loc - URL of the current page (on demand can be updated)
      * expiredMsg - a default message on "Session Expiration" event.

      Note:
      Until the version 1.0.5 the method can't be redefined on "Session Expiration" , a confirmation dialog with request for view reloading was always called.


      ------------------------------------ End of snippet.

      I put this javascript in my jsp, and put in an alert to see if the session expiration event was captured. I set my session expiration to 1 minute in my web.xml. But the alert never popped up. Does anyone have a real life example how to handle the session expiration using ajax4jsf? I would expect the browser to send a session expiration event to be fired, and the above said script to be invoked upon that event, and then popup the alert message.

      In the interim, I have found a quick and easy way to handle session expiration, and redirect the user to the login screen without ajax4jsf....

      add this to the head tag...

      <meta http-equiv="refresh" content="<%=session.getMaxInactiveInterval()%>;url=/login.jsf">