I want to display in a <p:growl>
that the session has expired.
I found many methods to handle session expiration like Session timeout and ViewExpiredException handling on JSF/PrimeFaces ajax request, but I couldn't push a faces message to <p:growl>
.
To the point, how can I automatically run some (JavaScript) code in client side when the HTTP session has automatically expired in server side?
Best Answer
You can use PrimeFaces idle monitor for this. User is redirected to logout action after timeout to invalidate the session. 2 minutes before a countdown dialog is shown to warn user. After moving the mouse again session is extended.
PrimeFaces idle monitor and dialog is placed in a template you can add to every page which is involved:
To activate timeout handling in multiple pages include the timeout template in your layout template:
A specific time out for your web application you can set in your web.xml:
You can read more about this solution in this blog post: JSF and PrimeFaces: Session Timeout Handling