I have a JSF 2.1 + Primefaces 5.1 web application and I want to handle ViewExpiredExceptions. Besides the configuration in web.xml (matching exceptions with location via <error-page>), I read that we need to handle these exceptions when they are thrown during ajax requests.
For this purpose, Primefaces is provided <p:ajaxExceptionHandler>. I tried using it, and although I saw that the exception was being thrown in the server log, I could not do anything. Maybe I'm using it the wrong way. How can I, for example, send a user to a page index.xhtmlwhen such an exception occurs, updating all ajax components?
I defined a factory exception handler in faces-config.xml:
<factory>
<exception-handler-factory>
org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory
</exception-handler-factory>
</factory>
And declared the facelets handler on my template page:
<p:ajaxExceptionHandler type="javax.faces.application.ViewExpiredException"/>
Here is my web.xml configuration for these exceptions:
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/index.xhtml</location>
</error-page>
After using this approach unsuccessfully, I tried explicitly defining an exception handler ( Check if a JSF session exists ), but without success.
Can someone tell me how to solve this problem? (I try to stick with simple JSF and Primefaces, although I know that Omnifaces provides a similar solution for Primefaces, but I have not tried it yet).
source
share