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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Unified Expression Language<br />

160<br />

property. In terms of the following expression, a BeanELResolver instance is called the first<br />

time to find the base object, employee, which is a <strong>Java</strong>Beans component. Once the resolver finds<br />

the object, it is called again to resolve the property, lName of the employee object.<br />

${employee.lName}<br />

<strong>The</strong> unified EL includes a set of standard resolver implementations. Table 5–4 lists these<br />

standard resolvers and includes example expressions that they can resolve.<br />

TABLE 5–4 Standard EL Resolvers<br />

Resolver Example Expression Description<br />

ArrayELResolver ${myArray[1]} Returns the value at index 1 in the array called<br />

myArray<br />

BeanELResolver ${employee.lName} Returns the value of the lName property of the<br />

employee bean<br />

ListELResolver ${myList[5]} Returns the value at index 5 of myList list<br />

MapELResolver ${myMap.someKey} Returns the value stored at the key, someKey,in<br />

the Map, myMap<br />

ResourceBundleELResolver ${myRB.myKey} Returns the message at myKey in the resource<br />

bundle called myRB<br />

Depending on the technology using the unified EL, other resolvers might be available. In<br />

addition, application developers can add their own implementations of ELResolver to support<br />

resolution of expressions not already supported by the unified EL by registering them with an<br />

application.<br />

All of the standard and custom resolvers available to a particular application are collected in a<br />

chain in a particular order. This chain of resolvers is represented by a CompositeELResolver<br />

instance. When an expression is encountered, the CompositeELResolver instance iterates over<br />

the list of resolvers and consults each resolver until it finds one that can handle the expression.<br />

If an application is using JSP technology, the chain of resolvers includes the<br />

ImplicitObjectELResolver and the ScopedAttributeELResolver. <strong>The</strong>se are described in the<br />

following section.<br />

See section JSP 2.9 of the <strong>Java</strong>Server Pages 2.1 specification to find out the order in which<br />

resolvers are chained together in a CompositeELResolver instance.<br />

To learn how to create a custom EL resolver, see <strong>The</strong> Unified Expression Language<br />

(http://java.sun.com/products/jsp/reference/techart/unifiedEL.html) .<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

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

Saved successfully!

Ooh no, something went wrong!