Java Reference
In-Depth Information
• The JavaServer Faces implementation can perform conversions on the data based
on the type of the bean property without the developer needing to apply a convert-
er.
In most situations, you will bind a component's value rather than its instance to a bean
property. You'll need to use a component binding only when you need to change one of
the component's attributes dynamically. For example, if an application renders a compon-
ent only under certain conditions, it can set the component's rendered property accord-
ingly by accessing the property to which the component is bound.
When referencing the property using the component tag's value attribute, you need to
use the proper syntax. For example, suppose a managed bean called MyBean has this int
property:
Click here to view code image
protected int currentOption = null;
public int getCurrentOption(){...}
public void setCurrentOption(int option){...}
The value attribute that references this property must have this value-binding expres-
sion:
#{myBean.currentOption}
In addition to binding a component's value to a bean property, the value attribute can
specify a literal value or can map the component's data to any primitive (such as int ),
structure (such as an array), or collection (such as a list), independent of a JavaBeans com-
ponent. Table 6-3 lists some example value-binding expressions that you can use with the
value attribute.
Search WWH ::




Custom Search