background image

Resolving Expressions

<< Composite Expressions | EL Resolvers >>
<< Composite Expressions | EL Resolvers >>

Resolving Expressions

Resolving Expressions
The unified EL introduces a new, pluggable API for resolving expressions. The main pieces of
this API are:
The ValueExpression class, which defines a value expression
The MethodExpression class, which defines a method expression
An ELResolver class that defines a mechanism for resolving expressions
A set of ELResolver implementations, in which each implementation is responsible for
resolving expressions that reference a particular type of object or property
An ELContext object that saves state relating to EL resolution, holds references to EL
resolvers, and contains context objects (such as JspContext) needed by the underlying
technology to resolve expressions
Most application developers will not need to use these classes directly unless they plan to write
their own custom EL resolvers. Those writing JavaServer Faces custom components will
definitely need to use ValueExpression and MethodExpression. This section details how
expressions are resolved for the benefit of these developers. It does not explain how to create a
custom resolver. For more information on creating custom resolvers, see the article The Unified
Expression Language, Ryan Lubke et al., located at
http://java.sun.com/products/jsp/reference/techart/unifiedEL.html
. You can also
refer to
"Request Processing" on page 1071
, which explains how the Duke's Bank application uses
a custom resolver.
Process of Expression Evaluation
When a value expression that is included in a page is parsed during an initial request for the
page, a ValueExpression object is created to represent the expression. Then, the
ValueExpression
object's getValue method is invoked. This method will in turn invoke the
getValue
method of the appropriate resolver. A similar process occurs during a postback when
setValue
is called if the expression is an lvalue expression.
In the case of a method expression, a BeanELResolver is used to find the object that implements
the method to be invoked or queried. Similarly to the process for evaluating value expressions,
when a method expression is encountered, a MethodExpression object is created.
Subsequently, either the invoke or getMethodInfo method of the MethodExpression object is
called. This method in turn invokes the BeanELResolver object's getValue method. The
getMethodInfo
is mostly for use by tools.
After a resolver completes resolution of an expression, it sets the propertyResolved flag of the
ELContext
to true so that no more resolvers are consulted.
Unified Expression Language
The Java EE 5 Tutorial · September 2007
160