10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Registering a Custom Converter<br />

<strong>The</strong> validator-id and validator-class elements are required subelements. <strong>The</strong><br />

validator-id element represents the identifier under which the Validator class should be<br />

registered. This ID is used by the tag class corresponding to the custom validator tag.<br />

<strong>The</strong> validator-class element represents the fully qualified class name of the Validator class.<br />

<strong>The</strong> attribute element identifies an attribute associated with the Validator implementation.<br />

It has required attribute-name and attribute-class subelements. <strong>The</strong> attribute-name<br />

element refers to the name of the attribute as it appears in the validator tag. <strong>The</strong><br />

attribute-class element identifies the <strong>Java</strong> type of the value associated with the attribute.<br />

“Creating a Custom Validator” on page 396 explains how to implement the Validator<br />

interface.<br />

“Using a Custom Validator” on page 373 explains how to reference the validator from the page.<br />

Registering a Custom Converter<br />

448<br />

As is the case with a custom validator, if the application developer creates a custom converter,<br />

you must register it with the application. Here is the converter configuration for<br />

CreditCardConverter from the Duke’s Bookstore application:<br />

<br />

<br />

Converter for credit card<br />

numbers that normalizes<br />

the input to a standard format<br />

<br />

CreditCardConverter<br />

<br />

com.sun.bookstore6.converters.CreditCardConverter<br />

<br />

<br />

<strong>The</strong> converter element represents a Converter implementation and contains required<br />

converter-id and converter-class elements.<br />

<strong>The</strong> converter-id element identifies an ID that is used by the converter attribute of a UI<br />

component tag to apply the converter to the component’s data. “Using a Custom Converter” on<br />

page 372 includes an example of referencing the custom converter from a component tag.<br />

<strong>The</strong> converter-class element identifies the Converter implementation.<br />

“Creating a Custom Converter” on page 391 explains how to create a custom converter.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!