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

Coercion Rules

The EL automatically converts, or coerces, variable values and the result of an expression to the type required by an operator:

To Java type

Conversion rule

String

null: to empty string (“”).

All other types: to the corresponding String value.

Primitive number or Number

null or empty string: 0.

Character or char: to the value represented by the character code.

String: parse as an Integer or Floating point literal.

Numeric types: coerce to the requested precision.

boolean or Boolean

null: to false.

String: to true if the value is “true”, ignoring case, otherwise false.

Other type

null: keep as null.

String: use the PropertyEditor for the requested type, if any, otherwise null if the string is empty.

Other: type cast, if possible.

In all cases, the EL evaluator throws an exception for attempts to convert between types not defined in the table or if the defined conversion rule fails.

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