10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

UserNumberBean.validate method, which performs validation of the component’s local value.<br />

<strong>The</strong> local value is whatever the user enters into the field corresponding to this tag. This method<br />

is invoked when the expression is evaluated, which is during the process validation phase of the<br />

life cycle.<br />

Nearly all <strong>Java</strong>Server Faces tag attributes accept value expressions. In addition to referencing<br />

bean properties, value expressions can also reference lists, maps, arrays, implicit objects, and<br />

resource bundles.<br />

Another use of value expressions is binding a component instance to a backing bean property.<br />

A page author does this by referencing the property from the binding attribute:<br />

<br />

Those component tags that use method expressions are UIInput component tags and<br />

UICommand component tags. See sections “Using Text Components” on page 328 and “Using<br />

Command Components for Performing Actions and Navigation” on page 333 for more<br />

information on how these component tags use method expressions.<br />

In addition to using expressions with the standard component tags, you can also configure your<br />

custom component properties to accept expressions by creating ValueExpression or<br />

MethodExpression instances for them. See “Creating Custom Component Classes” on page 417<br />

and “Enabling Component Properties to Accept Expressions” on page 422 for more information<br />

on enabling your component’s attributes to support expressions.<br />

To learn more about using expressions to bind to backing bean properties, see “Binding<br />

Component Values and Instances to External Data Sources” on page 362.<br />

For information on referencing backing bean methods from component tags, see “Referencing<br />

a Backing Bean Method” on page 368.<br />

<strong>The</strong> Life Cycle of a <strong>Java</strong>Server Faces Page<br />

<strong>The</strong> Life Cycle of a <strong>Java</strong>Server Faces Page<br />

<strong>The</strong> life cycle of a <strong>Java</strong>Server Faces page is somewhat similar to that of a JSP page: <strong>The</strong> client<br />

makes an HTTP request for the page, and the server responds with the page translated to<br />

HTML. However, the <strong>Java</strong>Server Faces life cycle differs from the JSP life cycle in that it is split up<br />

into multiple phases in order to support the sophisticated UI component model. This model<br />

requires that component data be converted and validated, component events be handled, and<br />

component data be propagated to beans in an orderly fashion.<br />

A <strong>Java</strong>Server Faces page is also different from a JSP page in that it is represented by a tree of UI<br />

components, called a view. During the life cycle, the <strong>Java</strong>Server Faces implementation must<br />

build the view while considering state saved from a previous submission of the page. When the<br />

client submits a page, the <strong>Java</strong>Server Faces implementation performs several tasks, such as<br />

validating the data input of components in the view and converting input data to types specified<br />

on the server side.<br />

Chapter 10 • <strong>Java</strong>Server FacesTechnology 311

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!