Venkat Maridu
Venkat Maridu

Reputation: 902

How to implement Session Timeout Handling using pimefaces?

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>

Upvotes: 0

Views: 6214

Answers (1)

Venkat Maridu
Venkat Maridu

Reputation: 902

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.

Upvotes: 0

Related Questions