如何创建类似数据表的组件,但以编程方式插入列?

发布于 2024-12-11 10:04:21 字数 184 浏览 0 评论 0原文

我必须显示一个具有大量列和行的二维表,并且二维不是固定的。使用 JSF2 dataTable 存在列数不能动态的约束:每个列必须具有正确的 jsf tag 。 有没有办法以编程方式插入数据表中的行的列? panelGrid 也不适合,因为您必须手动指定和编写所有标签。 我不喜欢使用 javascript 来创建这样的组件,我想尽可能地利用 JSF2。

I have to display a two dimensional table with a great number of columns and rows and the two dimensions are not fixed. Using JSF2 dataTable there is the constraint that the number of colums cannot be dynamic: each coloumn must have the proper jsf tag .
Is there a way to insert the columns programmatically as for the rows in the dataTable?
Also panelGrid does not suit because you have to specify and write all the tags by hand.
I prefer not to use javascript to create such a component, I would like to exploit JSF2 as much as possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞陪衬 2024-12-18 10:04:21

标准 JSF 组件集 没有这样的逻辑上将其命名为 的组件。然而,存在具有此类组件的第三方组件库。例如, TomahawkPrimeFaces。 Tomahawk 组件不会生成任何额外的外观,因此如果您想自己完全控制 CSS,那么这是完美的选择。 PrimeFaces 在 CSS themeroller 框架 的帮助下生成可自定义的外观,因此如果满足以下条件,这是完美的:您想利用 themeroller 来管理外观。

以下是如何使用 Tomahawk 的 的示例,从其 标签文档

<t:dataTable value="#{bean.rows}" var="row">
    <t:columns value="#{bean.columns}" var="column">
        <f:facet name="header">
            <h:outputText value="#{column.name}"/>
        </f:facet>
        <h:outputText value="#{row[column.name]}"/>
    </t:columns>
</t:dataTable>

The standard JSF component set does not have such a component where it would be logically named <h:columns>. There exist however 3rd party component libraries which have such a component. For example, Tomahawk with <t:columns> and PrimeFaces with <p:columns>. The Tomahawk components doesn't generate any additional look'n'feel, so this is perfect if you want full control over CSS yourself. The PrimeFaces one generates a customizeable look'n'feel with help of CSS themeroller framework, so this is perfect if you want to utilize themeroller to manage look'n'feel.

Here's an example of how you could use Tomahawk's <t:columns>, copied and slightly changed from its tag documentation:

<t:dataTable value="#{bean.rows}" var="row">
    <t:columns value="#{bean.columns}" var="column">
        <f:facet name="header">
            <h:outputText value="#{column.name}"/>
        </f:facet>
        <h:outputText value="#{row[column.name]}"/>
    </t:columns>
</t:dataTable>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文