数据表中元素的自定义渲染

Customized rendering of elements in datatable

我在数组列表中有 n 个元素,我想以 table of (n/3) X 3 格式显示所有这些元素(通过单个迭代)与相应数量的单选按钮,如

<table>
<tbody>
<tr>
  <td><input type="radio" name="category1" id="category1" value="1"></td>
  <td><input type="radio" name="category1" id="category1" value="2"></td>
  <td><input type="radio" name="category1" id="category1" value="3"></td>
</tr>
<tr>
  <td><input type="radio" name="category1" id="category1" value="4"></td>
  <td><input type="radio" name="category1" id="category1" value="5"></td>
  <td><input type="radio" name="category1" id="category1" value="6"></td>
</tr>
...
<tr>
  <td><input type="radio" name="category1" id="category1" value="n"></td>
  <td></td>
  <td></td>
</tr>
</tbody>
</table>

请帮忙

您可以只使用 h:panelGridc:forEach

<h:panelGrid columns="3">
    <c:forEach items="#{myBean.list}"  var="item">
        <h:outputText value="#{item}" />
    </c:forEach>
</h:panelGrid>

它将呈现 <table />

<tbody>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
    <tr>
        <td>4</td>
        <td>5</td>
        <td>6</td>
    </tr>
    ...
</tbody>