Possibilities for exception handling in PrimeFaces
PrimeFaces provides powerful exception handling for AJAX and non-AJAX requests out of the box. The mapping between error pages and exception types is configured via the error-page
ability in web.xml
. Exceptions for AJAX requests can also be configured via the special p:ajaxExceptionHandler
tag in order for them to be shown on the same page where they occurred. An implicit object, pfExceptionHandler
, provides useful information about exception details.
In this recipe, we will give helpful tips about configuration details and demonstrate PrimeFaces' exception handling for AJAX and non-AJAX requests.
Getting ready
In order to be able use the exception handling, a special EL resolver and a factory class for 'ExceptionHandler
of PrimeFaces should be registered in faces-config.xml
:
<application> <el-resolver> org.primefaces.application. exceptionhandler.PrimeExceptionHandlerELResolver </el-resolver> <...