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.

<br />

<br />

<br />

Hi. My name is Duke. I’m thinking of a number from<br />

to<br />

.<br />

Can you guess it?<br />

<br />

<br />

...<br />

<br />

<br />

<br />

See “Backing Beans” on page 307 for more information on creating beans, binding to bean<br />

properties, referencing bean methods, and configuring beans.<br />

See “Using Text Components” on page 328 for more information on the inputText tag.<br />

Registering aValidator on aText Field<br />

By nesting the validateLongRange tag within a text field’s component’s tag, the page author<br />

registers a LongRangeValidator onto the text field. This validator checks whether the<br />

component’s local data is within a certain range, defined by the validateLongRange tag’s<br />

minimum and maximum attributes.<br />

In the case of the greeting page, you need to validate the number the user enters into the text<br />

field. So, you add a validateLongRange tag inside the inputText tag. <strong>The</strong> maximum and minimum<br />

attributes of the validateLongRange tag get their values from the minimum and maximum<br />

properties of UserNumberBean using the value expressions #{UserNumberBean.minimum} and<br />

#{UserNumberBean.maximum}. See “Backing Beans” on page 307 for details on value<br />

expressions.<br />

After adding the validateLongRange tag, the page looks like this:<br />

<br />

<br />

<br />

<br />

Hi. My name is Duke. I’m thinking of a number from<br />

to<br />

.<br />

Can you guess it?<br />

<br />

A Simple <strong>Java</strong>Server Faces Application<br />

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

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

Saved successfully!

Ooh no, something went wrong!