background image

JavaServer Faces Technology,

<< Unified Expression Language | Immediate and Deferred Evaluation Syntax >>
<< Unified Expression Language | Immediate and Deferred Evaluation Syntax >>

JavaServer Faces Technology,

<c:if test=
"${sessionScope.cart.numberOfItems > 0}">
...
</c:if>
As explained in
"The Life Cycle of a JSP Page" on page 142
, JSP supports a simple
request/response life cycle, during which a page is executed and the HTML markup is rendered
immediately. Therefore, the simple, read-only expression language offered by JSP 2.0 was well
suited to the needs of JSP applications.
JavaServer Faces technology, on the other hand, features a multiphase life cycle designed to
support its sophisticated UI component model, which allows for converting and validating
component data, propagating component data to objects, and handling component events. To
facilitate these functions, JavaServer Faces technology introduced its own expression language
that included the following functionality:
Deferred evaluation of expressions
The ability to set data as well as get data
The ability to invoke methods
See
"Using the Unified EL to Reference Backing Beans" on page 312
for more information on
how to use the unified EL in JavaServer Faces applications.
These two expression languages have been unified for a couple reasons. One reason is so that
page authors can mix JSP content with JavaServer Faces tags without worrying about conflicts
caused by the different life cycles these technologies support. Another reason is so that other
JSP-based technologies could make use of the additional features similarly to the way JavaServer
Faces technology uses them. In fact, although the standard JSP tags and static content continue
to use only those features present in JSP 2.0, authors of JSP custom tags can create tags that take
advantage of the new set of features in the unified expression language.
To summarize, the new, unified expression language allows page authors to use simple
expressions to perform the following tasks:
Dynamically read application data stored in JavaBeans components, various data structures,
and implicit objects
Dynamically write data, such as user input into forms, to JavaBeans components
Invoke arbitrary static and public methods
Dynamically perform arithmetic operations
Unified Expression Language
Chapter 5 · JavaServer Pages Technology
147