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
exprAisnull, returnnullIf
exprBisnull, returnnullIf
exprAis aMapwith a key matchingexprB, return the valueIf
exprAis aListor array with an index matchingexprBcoerced to anint, return the valueIf
exprAis a bean with a property matchingexprBcoerced to aString, return the value.
When written, an expression of the form
#{exprA[exprB]} is evaluated according to the
following rules by default:
If
exprAisnull, throw aPropertyNotFoundExceptionIf
exprBisnull, throw aPropertyNotFoundExceptionIf
exprAis aMap, call itsput()method with the evaluation result ofexprBas the key and the component’s value as the valueIf
exprAis aListor array, call itsset()method or thejava.lang.reflect.Array.set()method with an index matchingexprBcoerced to anintand the component’s value. If an exception is thrown, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access