The Java EE 7 Tutorial
13.6 Handling Errors
JavaServer Faces handles Ajax errors through use of the onerror
attribute of the f:ajax
tag. The value of this attribute is the name of a JavaScript function.
When there is an error in processing a Ajax request, JavaServer Faces calls the defined onerror
JavaScript function and passes a data object to it. The data object contains all the properties available for the onevent
attribute and, in addition, the following properties:
-
description
-
errorName
-
errorMessage
The type
is error
. The status
property of the data object contains one of the valid error values listed in Table 13-4.
Table 13-4 Valid Error Values for the Data Object status Property
Values | Description |
---|---|
|
No Ajax response from server. |
|
One of the valid HTTP errors: |
|
The Ajax response is not well formed. |
|
The Ajax response contains an |
In the following example, any errors that occurred in processing the Ajax request are handled by the handlemyajaxerror
JavaScript function:
<f:ajax event="click" render="errormessage" onerror="handlemyajaxerror"/>