2

为了获取数据表的行号,我在这里得到了一个答案,我可以将 dataTable 直接绑定到视图(JSF 2 dataTable row index without dataModel)。

我在复合组件中使用该功能,同一页面中可能有几个。我相信绑定使得在每个页面上使用多个组件是不可能的;是否可以以某种方式“单独”绑定每个表?

4

2 回答 2

1

创建具有UIData属性的支持组件类。

@FacesComponent("fooComponent")
public class FooComponent extends UINamingContainer {

    private UIData table;

    // +getter +setter
}

并将其绑定到#{cc.table}#{cc}引用当前支持组件实例)。

<cc:interface componentType="fooComponent">
    ...
</cc:interface>
<cc:implementation>
    <h:dataTable binding="#{cc.table}" ...>
        <h:column>#{cc.table.rowIndex + 1}</h:column>
        ...
    </h:dataTable>
</cc:implementation>
于 2013-02-04T14:38:13.343 回答
0

只需使用 ui:repeat 代替,它已通过 varStatus.index 内置支持。

于 2015-03-08T00:45:23.253 回答