Java Reference
In-Depth Information
•
errorName
•
errorMessage
The
type
is
error
. The
status
property of the data object contains one of the valid
error values listed in
Table 4-4
.
TABLE 4-4. Valid Error Values for the Data Object
status
Property
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="test" onerror="handlemyajaxerror"/>
Receiving an Ajax Response
After the application sends an Ajax request, it is processed on the server side, and a re-
sponse is sent back to the client. As described earlier, Ajax allows for partial updating of
web pages. To enable such partial updating, JavaServer Faces technology allows for par-
tial processing of the view. The handling of the response is defined by the
render
attrib-
ute of the
f:ajax
tag.
Similar to the
execute
attribute, the
render
attribute defines which sections of the
page will be updated. The value of a
render
attribute can be one or more component
id
values, one of the keywords
@this
,
@all
,
@none
, and
@form
, or an EL expression. In
the following example, the
render
attribute simply identifies an output component to be
displayed when the Ajax action has successfully completed.
<h:commandButton id="submit" value="Submit">
<f:ajax execute="userNo" render="result" />
</h:commandButton>
<h:outputText id="result" value="#{userNumberBean.response}" />