background image

UIData Properties

<< Acceptable Types of Component Values | UISelectBoolean Properties >>
<< Acceptable Types of Component Values | UISelectBoolean Properties >>

UIData Properties

protected Date shipDate;
public Date getShipDate() {
return this.shipDate;
}
public void setShipDate(Date shipDate) {
this.shipDate = shipDate;
}
See
"Binding Component Values and Instances to External Data Sources" on page 364
for more
information on applying a Converter implementation.
UIData
Properties
UIData
components must be bound to one of the types listed in
Table 12­1
. The UIData
component from the bookshowcart.jsp page of the Duke's Bookstore example is discussed in
the section
"Using Data-Bound Table Components" on page 337
. Here is part of the start tag of
dataTable
from that section:
<h:dataTable
id=
"items"
...
value=
"#{cart.items}"
var=
"item" >
The value expression points to the items property of the ShoppingCart bean. The
ShoppingCart
bean maintains a map of ShoppingCartItem beans.
The getItems method from ShoppingCart populates a List with ShoppingCartItem instances
that are saved in the items map from when the customer adds books to the cart:
public synchronized List getItems() {
List results = new ArrayList();
results.addAll(this.items.values());
return results;
}
All the components contained in the UIData component are bound to the properties of the
ShoppingCart
bean that is bound to the entire UIData component. For example, here is the
outputText
tag that displays the book title in the table:
<h:commandLink action=
"#{showcart.details}">
<h:outputText value=
"#{item.item.title}"/>
</h:commandLink>
The book title is actually a hyperlink to the bookdetails.jsp page. The outputText tag uses
the value expression #{item.item.title} to bind its UIOutput component to the title
property of the Book bean. The first item in the expression is the ShoppingCartItem instance
that the dataTable tag is referencing while rendering the current row. The second item in the
Writing Bean Properties
The Java EE 5 Tutorial · September 2007
382