10 Replies Latest reply on Jan 1, 2009 1:31 PM by Ronald van Kuijk

    How to redirect the user to the last page he left when the session expires?

    Lijun Yan Newbie

      The business scenario here is: When a user attempts to access a page and the session has timed out, he is redirected to the login page with a message explaining that he need to log in again. After the user completes the log in, he should be redirected to the last page where he tried to interact.

      We didn't find any built-in Seam configuration could help with this requirement. So we implement it programmatically. We save the last view id to the Cookie when session times out, and then recover the last view id when the user re-logs in.

      We are wondering whether there is any Seam component we could take advantage of. With the coming org.jboss.seam.sessionExpired event, can we do something like:

      <event type="org.jboss.seam.sessionExpired">
           <action execute="#{redirect.captureCurrentView}"/>
       <event type="org.jboss.seam.postAuthenticate">
           <action execute="#{redirect.returnToCapturedView}"/>

      I tried this setting now, with the sessionExpired event developed as Jacob's blog, the error is:

      2008-03-18 16:33:51,313 ERROR *http-8080-2* SeamPhaseListener.beforePhase:120 [] uncaught exception
      javax.el.PropertyNotFoundException: Target Unreachable, identifier 'redirect' resolved to null

      We also have question about how the conversation plays in this redirection. For example, the session expires when the user is at some results page, when he re-logs in, how to keep all the result data on that page and other states? Basically how to save and replay a conversation?