background image

Properties Bound to Component Values

<< Developing with JavaServer Faces Technology | Acceptable Types of Component Values >>
<< Developing with JavaServer Faces Technology | Acceptable Types of Component Values >>

Properties Bound to Component Values

The UI component's tag binds the component's value to a property using its value attribute and
binds the component's instance to a property using its binding attribute, as explained in
"Binding Component Values and Instances to External Data Sources" on page 364
. Likewise, all
the converter, listener, and validator tags use their binding attributes to bind their associated
implementations to backing bean properties, as explained in
"Binding Converters, Listeners,
and Validators to Backing Bean Properties" on page 369
.
To bind a component's value to a backing bean property, the type of the property must match
the type of the component's value to which it is bound. For example, if a backing bean property
is bound to a UISelectBoolean component's value, the property should accept and return a
boolean
value or a Boolean wrapper Object instance.
To bind a component instance, the property must match the component type. For example, if a
backing bean property is bound to a UISelectBoolean instance, the property should accept and
return UISelectBoolean.
Similarly, in order to bind a converter, listener, or validator implementation to a property, the
property must accept and return the same type of converter, listener, or validator object. For
example, if you are using the convertDateTime tag to bind a DateTime converter to a property,
that property must accept and return a DateTime instance.
The rest of this section explains how to write properties that can be bound to component values,
to component instances for the component objects described in
"Adding UI Components to a
Page Using the HTML Component Tags" on page 327
, and to converter, listener, and validator
implementations.
Writing Properties Bound to Component Values
To write a backing bean property bound to a component's value, you must know the types that
the component's value can be so that you can make the property match the type of the
component's value.
Table 12­1
lists all the component classes described in
"Adding UI Components to a Page
Using the HTML Component Tags" on page 327
and the acceptable types of their values.
When page authors bind components to properties using the value attributes of the
component tags, they need to ensure that the corresponding properties match the types of the
components' values.
Writing Bean Properties
The Java EE 5 Tutorial · September 2007
380