在JSF中动态创建表列 [英] Create table columns dynamically in JSF

查看:133
本文介绍了在JSF中动态创建表列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用仪表板应用程序,在该应用程序中,我必须检索一组记录并在动态表框中显示.页面框架的长度是固定的.现在可以初始化列和行.它看起来像这样的示例:

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>

推荐答案

您可以使用<h:panelGrid>使用标准JSF组件来实现此目的,其中<c:forEach>用于在视图构建期间生成单元. <ui:repeat>在视图渲染期间无法正常运行.

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中动态创建表列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆