Java Reference
In-Depth Information
After dragging the JSF Data Table item into the appropriate location in our
registrationlist.jsp page, the following window pops up.
We can either select to create an Empty Table or a Table Generated from an
Entity Class .
An Entity Class refers to a Java Persistence API (JPA) entity. We will
discuss JPA in detail in Chapter 5 Interacting With Databases through the
Java Persistence API .
Selecting to create an empty table generates the following markup in our page:
<h:form>
<h:dataTable value="#{arrayOrCollectionOf}"
var="item">
</h:dataTable>
</h:form>
Notice that NetBeans automatically wraps the generated <h:dataTable> tag in an
<h:form> tag. The <h:form> tag is necessary if we plan to have any input fields in
our table. Since this is not the case in our example, we can safely delete it.
The value of the value attribute of <h:dataTable> typically resolves to an array
or collection of objects. NetBeans places the placeholder value binding expression
#{arrayOrCollectionOf} as its value; we must replace this with a value binding
expression resolving to one of the appropriate types.
The value of the var attribute of <h:dataTable> is used to refer to the current
element in the table. As we iterate through the elements of the array or collection
from the value attribute, we can use the value of the item attribute to refer to the
current element in the array or collection.
 
Search WWH ::




Custom Search