Homepage | Developers
AjaxErrorHandler
If a partial AJAX request returned some error, PrimeFaces based web application did not respond to this error and user didn't know, where is the problem and how he/she can continue to work. The most often problem with AJAX errors is, when some action / actionListener throws an unexpected exception and developer don't catch all exceptions (e.g. falied DB save operation or expired Session-, ViewScope).

Maybe you have also experienced that during development - user's actions has no affect after session expiration (no response from server). Because PrimeFaces ignores a lot of errors, finding out the real reason of problem takes a long time without any error information.

Component pe:ajaxErrorHandler is created to overcome these cases and provide a better AJAX error handling. The component enables message displaying in case of detection of an AJAX error. In case of need, you can define different behaviours for various types of errors.

The best way to understand the behaviour is through examples.

Simple and Extended mode

Component ajaxErrorHandler can be used in simple and extended mode. Extended mode is activated when our exception-handler-factory is used in faces-config.xml

<factory>
  <exception-handler-factory>
    <org.primefaces.extensions.component.ajaxerrorhandler.AjaxExceptionHandlerFactory
  </exception-handler-factory>
</factory>

Comparision of Simple and Extended mode
Simple modeExtended mode
all attributes in pe: ajaxErrorHandler (body, title, ...)OKOK
Variable {error-name}OKOK
Variable {error-message}OKOK
Variable {error-hostname}WARNING – value of error-hostname might be wrong when application runs on cluster and current node is changed during workOK
Variable {error-stacktrace}NOT WORKINGOK
facet (body, title) in pe:ajaxErrorHandler NOT WORKINGOK
Very custom layout definition – inner components in pe:ajaxErrorHandlerNOT WORKINGOK
Note: Extended mode – handler solves problem, when javax.faces.PARTIAL_STATE_SAVING=false and javax.faces.STATE_SAVING_METHOD=server are set in web.xml and session is lost (cannot be restored after ViewExpiredException)
Components and more
Documentation pe:ajaxErrorHandler
Attributes (move mouse over the names to see data types)
Name Description
id Unique identifier of the component in a naming container.
widgetVar Name of the client side widget. Allows to define widget name on frontend with methods hide() and isVisible(). If XHTML contain more ajaxErrorHandler with widgetWar, every widgetWar is the same JavaScript object
type Exception class name. If type is not defined, ajaxErrorHandler is defined for all exceptions. If type is defined, ajaxErrorHandler is defined for this type exception.
title Title text in popup ERROR BOX. Default is: {error-name}.
body Body text/html in popup ERROR BOX. Default is: {error-message}.
button Button text in popup ERROR BOX. Default is: Reload.
buttonOnclick Javascript function for Button in popup ERROR BOX. Default is JavaScript function for RELOAD content.
onerror Javascript function(error, response). This function is called before construct ERROR BOX on client side. If this function returns FALSE, follows steps are breaked and construct information with description.
PrimeFaces Extensions Showcase - © 2011-2013, PrimeFaces: 4.0, PrimeFaces Extensions: 1.1.0, JSF: mojarra 2.1.26, Server: jetty/8.1.0.RC2, Build time: 2013-11-11 21:02
Theme
afterdark
afternoon
afterwork
aristo
black-tie
blitzer
bluesky
bootstrap
casablanca
cruze
cupertino
dark-hive
delta
dot-luv
eggplant
excite-bike
flick
glass-x
home
hot-sneaks
humanity
le-frog
midnight
mint-choc
overcast
pepper-grinder
redmond
rocket
sam
smoothness
south-street
start
sunny
swanky-purse
trontastic
ui-darkness
ui-lightness
vader
Developers
Thomas Andraschko andraschko.thomas@gmail.com
Oleg Varaksin ovaraksin@googlemail.com
Nilesh Namdeo Mali nileshmali86@gmail.com
Mauricio Fenoglio fenoglio.mauricio@gmail.com
Pavol Slaný pavol.slany@gmail.com
Sudheer Jonna sudheer.jonna@gmail.com