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.

Referencing a Backing Bean Method<br />

{<br />

public void setConvertDate(DateTimeConverter convertDate) {<br />

convertDate.setPattern("<strong>EE</strong><strong>EE</strong><strong>EE</strong><strong>EE</strong>, MMM dd, yyyy");<br />

this.convertDate = convertDate;<br />

}<br />

See “Writing Properties Bound to Converters, Listeners, or Validators” on page 387 for more<br />

information on writing backing bean properties for converter, listener, and validator<br />

implementations.<br />

Referencing a Backing Bean Method<br />

368<br />

A component tag has a set of attributes for referencing backing bean methods that can perform<br />

certain functions for the component associated with the tag. <strong>The</strong>se attributes are summarized in<br />

Table 11–10.<br />

TABLE 11–10 Component Tag Attributes That Reference Backing Bean Methods<br />

Attribute Function<br />

action Refers to a backing bean method that performs navigation processing for the<br />

component and returns a logical outcome String<br />

actionListener Refers to a backing bean method that handles action events<br />

validator Refers to a backing bean method that performs validation on the component’s value<br />

valueChangeListener Refers to a backing bean method that handles value-change events<br />

Only components that implement ActionSource can use the action and actionListener<br />

attributes. Only components that implement EditableValueHolder can use the validator or<br />

valueChangeListener attributes.<br />

<strong>The</strong> component tag refers to a backing bean method using a method expression as a value of<br />

one of the attributes. <strong>The</strong> method referenced by an attribute must follow a particular signature,<br />

which is defined by the tag attribute’s definition in the TLD. For example, the definition of the<br />

validator attribute of the inputText tag in html_basic.tld is the following:<br />

void validate(javax.faces.context.FacesContext,<br />

javax.faces.component.UIComponent, java.lang.Object)<br />

<strong>The</strong> following four sections give examples of how to use the four different attributes.<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!