问题描述
我正在开发仪表板应用程序,我必须在其中检索一组记录并在动态表框中显示.页框长度是固定的.现在可以初始化列和行.它应该看起来像这个示例:
I'm working on dashboard application where I have to retrieve a set of records and display in dynamic tables boxes. Page frame length is fixed. now of columns and rows can be initialized. It should look like this sample:
目前我使用数据表来显示,但它将所有数据打印在一列中.如何将我的代码更改为上述模式?
Currently I'm using data table to display but it prints all the data in one column. How would I change my code to above pattern?
<o:dataTable id="tabBlSearch" var="item"
onkeyup="handleLeftRightArrowOnDataTable('frmDashBoard:tabBlSearch')"
value="#{bLDashBoardAction.listBondLoc}">
<o:column style="width: 20px;">
<h:outputText value="#{item.awb}" />
</o:column>
</o:dataTable>
推荐答案
您可以通过使用 的标准 JSF 组件实现这一点,其中
用于在视图构建期间生成单元格.
将无法工作,因为它在视图渲染时间运行.
You can achieve this with standard JSF components using a <h:panelGrid>
wherein <c:forEach>
is been used to generate the cells during the view build time. The <ui:repeat>
won't work as that runs during view render time.
<h:panelGrid columns="5">
<c:forEach items="#{bean.items}" var="item">
<h:panelGroup>
<h:outputText value="#{item.value}" />
</h:panelGroup>
</c:forEach>
</h:panelGrid>
至于组件库,我在 OpenFaces' 展示 中没有看到任何内容,但 PrimeFaces 有一个 正是为了这个目的,即使有分页支持.
As to component libraries, I don't see anything in OpenFaces' showcase, but PrimeFaces has a <p:dataGrid>
for exactly this purpose, even with pagination support.
<p:dataGrid columns="5" value="#{bean.items}" var="item">
<p:column>
<h:outputText value="#{item.value}" />
</p:column>
</p:dataGrid>
这篇关于在 JSF 中动态创建表列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!