Java Reference
In-Depth Information
TABLE 6-3. Examples of Value-Binding Expressions
The next two sections explain how to use the
value
attribute to bind a component's value
to a bean property or other data objects, and how to use the
binding
attribute to bind a
component instance to a bean property.
Binding a Component Value to a Property
To bind a component's value to a managed bean property, you specify the name of the
bean and the property using the
value
attribute.
This means that the first part of the EL value expression must match the name of the man-
aged bean up to the first period (
.
) and the part of the value expression after the period
must match the property of the managed bean.
For example, in the Duke's Bookstore case study, the
h:dataTable
tag in
bookcata-
log.xhtml
sets the value of the component to the value of the
books
property of the
stateless session bean
BookRequestBean
:
<h:dataTable id="books"
value="#{bookRequestBean.books}"
var="book"
headerClass="list-header"
styleClass="list-background"
rowClasses="list-row-even, list-row-odd"
border="1"
summary="#{bundle.BookCatalog}" >
The value is obtained by calling the bean's
getBooks
method.