You use the Insert JSF Data Table dialog box to generate JSF data table in a JSP page. A JSF data table is a JSF component that provides a way of iterating over each entry in a data source and displaying the entry's information in an HTML table. You open the dialog box by opening any JSP file and dragging the JSF Data Table item from the Palette window into the desired location in the JSP file.
You can generate either of the following:
<f:view> <h:form> <h:dataTable value="#{arrayOrCollectionOf}" var="item"> </h:dataTable> </h:form> </f:view>
In the generated code, you have to replace the arrayOrCollectionOf variable with a property in a JSF managed bean that holds all of the items in your data source. You then code a data column for each of the data source's columns that you want to display in the file.
The IDE enters the following code in the page:
<f:view> <h:form> <h1><h:outputText value="List"/></h1> <h:dataTable value="#{arrayOrCollectionOfclass-name}" var="item"> <h:column> <f:facet name="header"> <h:outputText value="column1"/> </f:facet> <h:outputText value="#{item.column1}"/> </h:column> ... </h:dataTable> </h:form> </f:view>
In the generated code, you have to replace the arrayOrCollectionOfclass-name variable with a property in a JSF managed bean that holds all of the entries in the data source. Note that the JSF managed bean is often not the entity class itself but a separate controller class.
Notes:
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>