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.

Referencing a Backing Bean Method<br />

370<br />

“Writing a Method to Handle an Action Event” on page 404 describes how to implement a<br />

method that handles an action event.<br />

Referencing a MethodThat PerformsValidation<br />

If the input of one of the components on your page is validated by a backing bean method, you<br />

refer to the method from the component’s tag using the validator attribute.<br />

<strong>The</strong> Coffee Break application includes a method that performs validation of the email input<br />

component on the checkoutForm.jsp page. Here is the tag corresponding to this component:<br />

<br />

This tag references the validate method described in “Writing a Method to Perform<br />

Validation” on page 404 using a method expression.<br />

Referencing a MethodThat Handles aValue-change<br />

Event<br />

If you want a component on your page to generate a value-change event and you want that<br />

event to be handled by a backing bean method, you refer to the method using the component’s<br />

valueChangeListener attribute.<br />

<strong>The</strong> name component on the bookcashier.jsp page of the Duke’s Bookstore application<br />

references a ValueChangeListener implementation that handles the event of a user entering a<br />

name in the name input field:<br />

<br />

<br />

<br />

For illustration, “Writing a Method to Handle a Value-Change Event” on page 405 describes<br />

how to implement this listener with a backing bean method instead of a listener<br />

implementation class. To refer to this backing bean method, the tag uses the<br />

valueChangeListener attribute:<br />

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

Saved successfully!

Ooh no, something went wrong!