0

I am trying for Session Timeout Handling for my application for every 30 minutes. My specification: That I have to redirect to a login page when fails in login after user session is invalid.

User is redirected to logout action after timeout to invalidate the session.

I am new to prime faces and I have tried this but no use:

<session-config>
    <session-timeout> 1 </session-timeout>

    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>faces/login.xhtml</location>
    </error-page>
</session-config>
Venkat Maridu
  • 892
  • 3
  • 22
  • 45
  • possible duplicate of [Session timeout and ViewExpiredException handling on JSF/PrimeFaces ajax request](http://stackoverflow.com/questions/11203195/session-timeout-and-viewexpiredexception-handling-on-jsf-primefaces-ajax-request) – BalusC Jan 10 '13 at 12:38

1 Answers1

0

Finally got the solution I am using p:idleMonitor here. It will take care internally

<p:idleMonitor timeout="#{login.sessionTimeoutInterval}">
        <p:ajax event="idle" listener="#{login.sessionIdleListener}" /> 
    </p:idleMonitor> 

    <p:confirmDialog  closable="false" id="sessionExpiredDlg" 
                      message="Your session expired."  
                     header="#{msgs['confirmDialog.initiatingDestroyProcess.label']}"
                     severity="alert" widgetVar="sessionExpiredConfirmation" style="z-index: 25000">  

   <p:commandButton id="confirmRouteDel" value="Ok"
                                       oncomplete="sessionExpiredConfirmation.hide()" 
                                       actionListener="#{login.logoutAction}"/>

Java Method:

public void sessionIdleListener() {
        RequestContext context = RequestContext.getCurrentInstance();
        context.execute("sessionExpiredConfirmation.show()");
    }

Take a look at this once.

http://www.primefaces.org/showcase/ui/misc/idleMonitor.xhtml

It have two examples in it.

bakcsa83
  • 405
  • 1
  • 7
  • 20
Venkat Maridu
  • 892
  • 3
  • 22
  • 45