4

I have a JSF 2.1 + Primefaces 5.1 web application and I want to handle ViewExpiredExceptions. Besides the configuration in web.xml (mapping the exception to a location via <error-page>), I read that we need to treat these exceptions when they are thrown during ajax requests.

Primefaces provides a <p:ajaxExceptionHandler> for this purpose. I tried to use it and, although I could see the exception being thrown in the server log, I could not do anything else. Maybe I'm using it the wrong way. How could I, for instance, send the user to the index.xhtml page when such an exception occurs, refreshing all ajax components?

I defined the exception handler factory in faces-config.xml:

<factory>
   <exception-handler-factory>
      org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory
   </exception-handler-factory>
</factory>

And declared the facelets handler in my template page:

<p:ajaxExceptionHandler type="javax.faces.application.ViewExpiredException"/>

Here's my web.xml configuration for these exceptions:

<error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/index.xhtml</location>
    </error-page>

After being unsuccessful with this approach, I tried the explicit definition of the exception handler (Check if session exists JSF) but without success either.

Can anyone tell me how to solve this problem? (I'm trying to stick with plain JSF and Primefaces, although I know that Omnifaces provides a similar solution to Primefaces', but I haven't tried it yet).

Community
  • 1
  • 1
Baderous
  • 1,069
  • 1
  • 11
  • 32

0 Answers0