background image

Converter Instance

<< Backing Beans | Configuring a Bean >>
<< Backing Beans | Configuring a Bean >>

Converter Instance

Each of the component properties can be bound to one of the following:
A component's value
A component instance
A converter instance
A listener instance
A validator instance
The most common functions that backing bean methods perform include the following:
Validating a component's data
Handling an event fired by a component
Performing processing to determine the next page to which the application must navigate
As with all JavaBeans components, a property consists of a private data field and a set of
accessor methods, as shown by this code from the Guess Number example:
Integer userNumber = null;
...
public void setUserNumber(Integer user_number) {
userNumber = user_number;
}
public Integer getUserNumber() {
return userNumber;
}
public String getResponse() {
...
}
Because backing beans follow JavaBeans component conventions, you can reference beans
you've already written from your JavaServer Faces pages.
When a bean property is bound to a component's value, it can be any of the basic primitive and
numeric types or any Java object type for which the application has access to an appropriate
converter. For example, a property can be of type Date if the application has access to a
converter that can convert the Date type to a String and back again. See
"Writing Bean
Properties" on page 379
for information on which types are accepted by which component tags.
When a bean property is bound to a component instance, the property's type must be the same
as the component object. For example, if a UISelectBoolean is bound to the property, the
property must accept and return a UISelectBoolean object.
Likewise, if the property is bound to a converter, validator, or listener instance then the
property must be of the appropriate converter, validator, or listener type.
For more information on writing beans and their properties, see
"Writing Bean Properties" on
page 379
.
Backing Beans
The Java EE 5 Tutorial · September 2007
310