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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using the Standard Converters<br />

This message replaces the corresponding message queued on the component and will display<br />

wherever the message or messages tag is placed on the page.<br />

See “Registering Custom Error Messages” on page 445 and “Registering Custom Localized Static<br />

Text” on page 446 for information on how to use the message-bundle and resource-bundle<br />

element to register resource bundles that contain error messages.<br />

Using the Standard Converters<br />

352<br />

<strong>The</strong> <strong>Java</strong>Server Faces implementation provides a set of Converter implementations that you<br />

can use to convert component data. For more information on the conceptual details of the<br />

conversion model, see “Conversion Model” on page 302.<br />

<strong>The</strong> standard Converter implementations, located in the javax.faces.convert package, are<br />

as follows:<br />

■ BigDecimalConverter<br />

■ BigIntegerConverter<br />

■ BooleanConverter<br />

■ ByteConverter<br />

■ CharacterConverter<br />

■ DateTimeConverter<br />

■ DoubleConverter<br />

■ FloatConverter<br />

■ IntegerConverter<br />

■ LongConverter<br />

■ NumberConverter<br />

■ ShortConverter<br />

Each of these converters has a standard error message associated with them. If you have<br />

registered one of these converters onto a component on your page, and the converter is not able<br />

to convert the component’s value, the converter’s error message will display on the page. For<br />

example, the error message that displays if BigIntegerConverter fails to convert a value is:<br />

{0} must be a number consisting of one or more digits<br />

In this case the {0} substitution parameter will be replaced with the name of the input<br />

component on which the converter is registered. See section 2.4.5 of the <strong>Java</strong>Server Faces<br />

specification, version 1.2, for a complete list of error messages.<br />

Two of the standard converters (DateTimeConverter and NumberConverter) have their own<br />

tags, which allow you to configure the format of the component data using the tag attributes.<br />

“Using DateTimeConverter” on page 354 discusses using DateTimeConverter. “Using<br />

NumberConverter” on page 355 discusses using NumberConverter. <strong>The</strong> following section<br />

explains how to convert a component’s value including how to register the other standard<br />

converters with a component.<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!