Operand Evaluation and Coercing Rules
Before the operator is applied, the EL evaluator coerces the types of the operand values. An exception is thrown if no rule matches, the coercing fails, or applying the operator leads to an exception.
Property and array accessor operators
An expression of the form #{exprA.identifierB}
is
evaluated the same way as #{exprA['identifierB']}
.
When used as value binding expression to bind an input
component’s value to a property of an application
bean, the expression is used both to read and write the property
value.
When read, an expression of the form
#{exprA[exprB]}
is evaluated according to the
following rules by default:
If
exprA
isnull
, returnnull
If
exprB
isnull
, returnnull
If
exprA
is aMap
with a key matchingexprB
, return the valueIf
exprA
is aList
or array with an index matchingexprB
coerced to anint
, return the valueIf
exprA
is a bean with a property matchingexprB
coerced to aString
, return the value.
When written, an expression of the form
#{exprA[exprB]}
is evaluated according to the
following rules by default:
If
exprA
isnull
, throw aPropertyNotFoundException
If
exprB
isnull
, throw aPropertyNotFoundException
If
exprA
is aMap
, call itsput()
method with the evaluation result ofexprB
as the key and the component’s value as the valueIf
exprA
is aList
or array, call itsset()
method or thejava.lang.reflect.Array.set()
method with an index matchingexprB
coerced to anint
and the component’s value. If an exception is thrown, ...
Get JavaServer Faces now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.