Java Reference
In-Depth Information
Monitoring Events on the Client
The ongoing Ajax requests can be monitored by using the
onevent
attribute of the
f:ajax
tag. The value of this attribute is the name of a JavaScript function. JavaServer
Faces calls the
onevent
function at each stage of the processing of an Ajax request: be-
gin, complete, and success.
When calling the JavaScript function assigned to the
onevent
property, JavaServer
Faces passes a data object to it. The data object contains the properties listed in
Table 4-3
.
TABLE 4-3. Properties of the
onEvent
Data Object
By using the
status
property of the data object, you can identify the current status
of the Ajax request and monitor its progress. In the following example,
mon-
itormyajaxevent
is a JavaScript function that monitors the Ajax request sent by the
event:
<f:ajax event="click" render="errormessage"
onevent="monitormyajaxevent"/>
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 proper-
ties:
•
description