Create h:column components inside h:dataTable based on a list of column names

前端 未结 1 1104
-上瘾入骨i
-上瘾入骨i 2021-01-25 00:29

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

相关标签:
1条回答
  • 2021-01-25 00:48

    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>
    
    0 讨论(0)
提交回复
热议问题