Java Reference
In-Depth Information
Note
Behind the scenes, the jsf.ajax.request() method of the
JavaScript resource library collects the data provided by the f:ajax
tag and posts the request to the JavaServer Faces lifecycle.
Using the event Attribute
The event attribute defines the event that triggers the Ajax action. Some of the possible
values for this attribute are click , keyup , mouseover , focus , and blur .
If not specified, a default event based on the parent component will be applied. The
default event is action for javax.faces.component.ActionSource compon-
ents such as a commandButton , and valueChange for
javax.faces.component.EditableValueHolder components such as in-
putText . In the following example, an Ajax tag is associated with the button compon-
ent, and the event that triggers the Ajax action is a mouse click:
Click here to view code image
<h:commandButton id="submit" value="Submit">
<f:ajax event="click" />
</h:commandButton>
<h:outputText id="result" value="#{userNumberBean.response}" />
Note
You may have noticed that the listed events are very similar to
JavaScript events. In fact, they are based on JavaScript events, but do
not have the on prefix.
For a command button, the default event is click , so that you do not actually need to
specify event="click" to obtain the desired behavior.
Using the execute Attribute
The execute attribute defines the component or components to be executed on the serv-
er. The component is identified by its id attribute. You can specify more than one execut-
able component. If more than one component is to be executed, specify a space-delimited
list of components.
When a component is executed, it participates in all phases of the request processing life-
cycle except the Render Response phase.
Search WWH ::




Custom Search