background image

The Life Cycle of a JavaServer Faces Page

<< Using the Unified EL | JavaServer Faces Implementation >>
<< Using the Unified EL | JavaServer Faces Implementation >>

The Life Cycle of a JavaServer Faces Page

UserNumberBean.validate
method, which performs validation of the component's local value.
The local value is whatever the user enters into the field corresponding to this tag. This method
is invoked when the expression is evaluated, which is during the process validation phase of the
life cycle.
Nearly all JavaServer Faces tag attributes accept value expressions. In addition to referencing
bean properties, value expressions can also reference lists, maps, arrays, implicit objects, and
resource bundles.
Another use of value expressions is binding a component instance to a backing bean property.
A page author does this by referencing the property from the binding attribute:
<inputText binding=
"#{UserNumberBean.userNoComponent}" />
Those component tags that use method expressions are UIInput component tags and
UICommand
component tags. See sections
"Using Text Components" on page 330
and
"Using
Command Components for Performing Actions and Navigation" on page 335
for more
information on how these component tags use method expressions.
In addition to using expressions with the standard component tags, you can also configure your
custom component properties to accept expressions by creating ValueExpression or
MethodExpression
instances for them. See
"Creating Custom Component Classes" on page 419
and
"Enabling Component Properties to Accept Expressions" on page 424
for more information
on enabling your component's attributes to support expressions.
To learn more about using expressions to bind to backing bean properties, see
"Binding
Component Values and Instances to External Data Sources" on page 364
.
For information on referencing backing bean methods from component tags, see
"Referencing
a Backing Bean Method" on page 370
.
The Life Cycle of a JavaServer Faces Page
The life cycle of a JavaServer Faces page is somewhat similar to that of a JSP page: The client
makes an HTTP request for the page, and the server responds with the page translated to
HTML. However, the JavaServer Faces life cycle differs from the JSP life cycle in that it is split up
into multiple phases in order to support the sophisticated UI component model. This model
requires that component data be converted and validated, component events be handled, and
component data be propagated to beans in an orderly fashion.
A JavaServer Faces page is also different from a JSP page in that it is represented by a tree of UI
components, called a view. During the life cycle, the JavaServer Faces implementation must
build the view while considering state saved from a previous submission of the page. When the
client submits a page, the JavaServer Faces implementation performs several tasks, such as
validating the data input of components in the view and converting input data to types specified
on the server side.
The Life Cycle of a JavaServer Faces Page
Chapter 10 · JavaServer Faces Technology
313