background image

Referencing a Backing Bean Method

<< Binding Converters, Listeners, and Validators | Referencing a Method >>
<< Binding Converters, Listeners, and Validators | Referencing a Method >>

Referencing a Backing Bean Method

{
public void setConvertDate(DateTimeConverter convertDate) {
convertDate.setPattern(
"EEEEEEEE, MMM dd, yyyy");
this.convertDate = convertDate;
}
See
"Writing Properties Bound to Converters, Listeners, or Validators" on page 389
for more
information on writing backing bean properties for converter, listener, and validator
implementations.
Referencing a Backing Bean Method
A component tag has a set of attributes for referencing backing bean methods that can perform
certain functions for the component associated with the tag. These attributes are summarized in
Table 11­10
.
TABLE 11­10
Component Tag Attributes That Reference Backing Bean Methods
Attribute
Function
action
Refers to a backing bean method that performs navigation processing for the
component and returns a logical outcome String
actionListener
Refers to a backing bean method that handles action events
validator
Refers to a backing bean method that performs validation on the component's value
valueChangeListener
Refers to a backing bean method that handles value-change events
Only components that implement ActionSource can use the action and actionListener
attributes. Only components that implement EditableValueHolder can use the validator or
valueChangeListener
attributes.
The component tag refers to a backing bean method using a method expression as a value of
one of the attributes. The method referenced by an attribute must follow a particular signature,
which is defined by the tag attribute's definition in the TLD. For example, the definition of the
validator
attribute of the inputText tag in html_basic.tld is the following:
void validate(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
The following four sections give examples of how to use the four different attributes.
Referencing a Backing Bean Method
The Java EE 5 Tutorial · September 2007
370