Registering a Custom Converter

As is the case with a custom validator, if the application developer creates a custom converter, you must register it with the application. Here is the converter configuration for CreditCardConverter from the Duke's Bookstore application:

<converter>
  <description>
    Converter for credit card numbers
    that normalizes the input to a standard
    format
  </description>
  <converter-id>creditcard</converter-id>
  <converter-class>
    converters.CreditCardConverter
  </converter-class>
</converter>

The converter element represents a Converter implementation and contains required converter-id and converter-class elements.

The converter-id element identifies an ID that is used by the converter attribute of a UI component tag to apply ...

Get The J2EE™ Tutorial Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.