I\'m trying to create a
using two lists. One list contains the column names and the other one contains the data that will populate the table. I
Yes, you can if you use <c:forEach>
to iterate over the column names and generate the <h:column>
components necessary for <h:dataTable>
. You can use the brace notation []
in EL to use the column name as a "dynamic" bean property name (or even as a Map
key).
<h:dataTable value="#{bean.rows}" var="row">
<c:forEach items="#{bean.columnNames}" var="columnName">
<h:column>#{row[columnName]}</h:column>
</c:forEach>
</h:dataTable>