JSF Tip #25 - The default JSF Converters

Whenever the JSF runtime needs to perform a conversion it uses a Converter to do so. As explained in previous blog entries you have the ability to implement your own Converter. But does that mean you need to implement it for simple conversions? No, you do not, the default JSF converters come to the rescue!


  Java Datatype                   JSF Converter

  java.lang.Boolean                javax.faces.convert.BooleanConverter
  java.lang.Byte                   javax.faces.convert.ByteConverter
  java.lang.Character              javax.faces.convert.CharacterConverter
  java.lang.Double                 javax.faces.convert.DoubleConverter
  java.lang.Enum                   javax.faces.convert.EnumConverter
  java.lang.Float                  javax.faces.convert.FloatConverter
  java.lang.Integer                javax.faces.convert.IntegerConverter
  java.lang.Long                   javax.faces.convert.LongConverter
  java.lang.Short                  javax.faces.convert.ShortConverter
  java.math.BigDecimal             javax.faces.convert.BigDecimalConverter
  java.math.BigInteger             javax.faces.convert.BigIntegerConverter
  java.util.Date                   javax.faces.convert.DateTimeConverter
        

Note that primitive values get auto-boxed to the object equivalent and are then converted using the mapping to the Converter mentioned in the above table.

Posted December 26, 2012

Up