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.

Navigation Model<br />

Validation Model<br />

<strong>Java</strong>Server Faces technology supports a mechanism for validating the local data of editable<br />

components (such as text fields). This validation occurs before the corresponding model data is<br />

updated to match the local value.<br />

Like the conversion model, the validation model defines a set of standard classes for performing<br />

common data validation checks. <strong>The</strong> <strong>Java</strong>Server Faces core tag library also defines a set of tags<br />

that correspond to the standard Validator implementations. See Table 11–7 for a list of all the<br />

standard validation classes and corresponding tags.<br />

Most of the tags have a set of attributes for configuring the validator’s properties, such as the<br />

minimum and maximum allowable values for the component’s data. <strong>The</strong> page author registers<br />

the validator on a component by nesting the validator’s tag within the component’s tag.<br />

<strong>The</strong> validation model also allows you to create your own custom validator and corresponding<br />

tag to perform custom validation. <strong>The</strong> validation model provides two ways to implement<br />

custom validation:<br />

■ Implement a Validator interface that performs the validation. See “Implementing the<br />

Validator Interface” on page 397 for more information.<br />

■ Implement a backing bean method that performs the validation. See “Writing a Method to<br />

Perform Validation” on page 404 for more information.<br />

If you are implementing a Validator interface, you must also:<br />

Navigation Model<br />

■ Register the Validator implementation with the application. See “Registering a Custom<br />

Validator” on page 447 for more information.<br />

■ Create a custom tag or use a validator tag to register the validator on the component. See<br />

“Creating a Custom Tag” on page 400 for more information.<br />

If you are implementing a backing bean method to perform validation, you also must reference<br />

the validator from the component tag’s validator attribute. See “Referencing a Method That<br />

Performs Validation” on page 370 for more information.<br />

<strong>The</strong> <strong>Java</strong>Server Faces navigation model makes it easy to define page navigation and to handle<br />

any additional processing needed to choose the sequence in which pages are loaded.<br />

As defined by <strong>Java</strong>Server Faces technology, navigation is a set of rules for choosing the next page<br />

to be displayed after a button or hyperlink is clicked. <strong>The</strong>se rules are defined by the application<br />

architect in the application configuration resource file (see “Application Configuration<br />

Resource File” on page 435) using a small set of XML elements.<br />

Chapter 10 • <strong>Java</strong>Server FacesTechnology 305

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

Saved successfully!

Ooh no, something went wrong!