background image

Acceptable Types of Component Values

<< Properties Bound to Component Values | UIData Properties >>
<< Properties Bound to Component Values | UIData Properties >>

Acceptable Types of Component Values

TABLE 12­1
Acceptable Types of Component Values
Component
Acceptable Types of Component Values
UIInput
, UIOutput,
UISelectItem
, UISelectOne
Any of the basic primitive and numeric types or any Java programming
language object type for which an appropriate Converter implementation
is available.
UIData
array
of beans, List of beans, single bean, java.sql.ResultSet,
javax.servlet.jsp.jstl.sql.Result
, javax.sql.RowSet.
UISelectBoolean
boolean
or Boolean.
UISelectItems
java.lang.String
, Collection, Array, Map.
UISelectMany
array
or List. Elements of the array or List can be any of the standard
types.
UIInput
and UIOutput Properties
The following tag binds the name component to the name property of CashierBean.
<h:inputText id=
"name" size="50"
value=
"#{cashier.name}"
required=
"true">
<f:valueChangeListener
type=
"com.sun.bookstore6.listeners.NameChanged" />
</h:inputText>
Here is the bean property bound to the name component:
protected String name = null;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
As
"Using the Standard Converters" on page 354
describes, to convert the value of a UIInput or
UIOutput
component, you can either apply a converter or create the bean property bound to the
component with the desired type. Here is the example tag explained in
"Using
DateTimeConverter
" on page 356
that displays the date books will be shipped:
<h:outputText value=
"#{cashier.shipDate}">
<f:convertDateTime dateStyle=
"full" />
</h:outputText>
The application developer must ensure that the property bound to the component represented
by this tag has a type of java.util.Date. Here is the shipDate property in CashierBean:
Writing Bean Properties
Chapter 12 · Developing with JavaServer Faces Technology
381