O'Reilly logo

JavaServer Faces by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. If exprA is null, return null

  2. If exprB is null, return null

  3. If exprA is a Map with a key matching exprB, return the value

  4. If exprA is a List or array with an index matching exprB coerced to an int, return the value

  5. If exprA is a bean with a property matching exprB coerced to a String, return the value.

When written, an expression of the form #{exprA[exprB]} is evaluated according to the following rules by default:

  1. If exprA is null, throw a PropertyNotFoundException

  2. If exprB is null, throw a PropertyNotFoundException

  3. If exprA is a Map, call its put() method with the evaluation result of exprB as the key and the component’s value as the value

  4. If exprA is a List or array, call its set() method or the java.lang.reflect.Array.set() method with an index matching exprB coerced to an int and the component’s value. If an exception is thrown, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required