I'm trying to create and populate a dataTable dynamically. By this I mean that we don't know when the JSP is being written the number of columns that will be in dataTable or how many rows. I suspect this can be done in Java code but I need to see if it's possible to do without introducing richFaces dependency in Java.
What I did was write my backing bean so that it returns a java.util.List of column headers which I use c:forEach to iterate through and create column headers. That's works fine. The 'value' attribute for the dataTable is a java.util.List of a RowEntry objects. There is one RowEntry object in the list for each row in the table and it contains a java.util.List with an entry for each column cell in the row. My JSP tried to use another forEach tag where the items value was that list but it always fails. My JSP looks like:
<rich:dataTable cellpadding="0" cellspacing="0" value="#{dynamictablebb.rowList}" styleClass="DataGrid" rowClasses="ListRow" var="cellvar"> <f:facet name="header"> <rich:columnGroup> <c:forEach var="avar" items="#{dynamictablebb.colHeaderList}"> <rich:column styleClass="richFacesColClass" > <h:outputText value="#{avar}" styleClass="ListHeading"/> </rich:column> </c:forEach> </rich:columnGroup> </f:facet> <c:forEach var="t" items="#{cellvar.rowEntries}"> <rich:column> <h:outputText value="{t}"/> </rich:column> </c:forEach> </rich:dataTable>
javax.servlet.ServletException: Don't know how to iterate over supplied "items" in <forEach>
<rich:column> <h:outputText value="#{cellvar.rowEntries}"/> </rich:column>