Java Reference
In-Depth Information
However, more often than not, the render attribute is likely to be associated with an
event attribute. In the following example, an output component is displayed when the
button component is clicked.
Click here to view code image
<h:commandButton id="submit" value="Submit">
<f:ajax event="click" execute="userNo" render="result"/>
</h:commandButton>
<h:outputText id="result" value="#{userNumberBean.response}"/>
Note
Behind the scenes, once again the jsf.ajax.request() method
handles the response. It registers a response-handling callback when the
original request is created. When the response is sent back to the client,
the callback is invoked. This callback automatically updates the client-
side DOM to reflect the rendered response.
Ajax Request Lifecycle
An Ajax request varies from other typical JavaServer Faces requests, and its processing is
also handled differently by the JavaServer Faces lifecycle.
As described in “ Partial Processing and Partial Rendering ” on page 56 , when an Ajax
request is received, the state associated with that request is captured by the
javax.faces.context.PartialViewContext . This object provides access to
information such as which components are targeted for processing/rendering. The pro-
cessPartial method of PartialViewContext uses this information to perform
partial component tree processing and rendering.
The execute attribute of the f:ajax tag identifies which segments of the server side
component tree should be processed. Because components can be uniquely identified in
the JavaServer Faces component tree, it is easy to identify and process a single compon-
ent, a few components, or a whole tree. This is made possible by the visitTree method
of the javax.faces.component.UIComponent class. The identified components
then run through the JavaServer Faces request lifecycle phases.
Similar to the execute attribute, the render attribute identifies which segments of the
JavaServer Faces component tree need to be rendered during the render response phase.
Search WWH ::




Custom Search