Skip to main content
Last updated September 07, 2011 22:47, by Kin-man Chung
==Type Converter== In EL 3.0, type coercions are controlled by the abstract class [ TypeConverter]. [ ELContext] contains an instance of this class, and is used for all type coercions in expression evaluations. [ StandardTypeConverter] extends TypeConverter to implemented the conversion rules in the spec. To plug in a customized TypeConverter, this class can be extended to provide conversions for a specific source and target type, using [ ELManager]'s new method setTypeConverter. <pre name="java"> elManager.setTypeConverter(new StandardTypeConverter { public <T> T coerceToType(Object obj, Class<T> targetType) { if ((obj instanceof Foo && targetType == String.class) { return /*specific Foo to String conversion*/; } return super.coerceToType(obj, targetType); } }); </pre>
Please Confirm