小编Cri*_*byJ的帖子

使用insertChildren并获取子属性

我实际上是在尝试创建自定义复合表组件,因为h:datatable或p:datatable不符合我的需要.然而,它应该像primefaces数据表一样使用.后,我发现JSF复合材料构件儿童揭露名单的项目,而复合材料部件内迭代我看到了终点线,但现在我卡住了.

我的xhtml:

<h:body>
    <sm:datatable mode="columntoggle" id="mytable" value="#{managerBean.objects}" var="object">
        <sm:column header="KeyHeader" property="key">
            <h:outputText value="#{object.key}"/>    
        </sm:column>
        <sm:column header="ValueHeader" property="value">
            <h:outputText value="#{object.value}"/>    
        </sm:column>
    </sm:datatable>
</h:body>
Run Code Online (Sandbox Code Playgroud)

这是数据表复合:

<cc:interface>
    <cc:attribute name="id" />
    <cc:attribute name="mode" />
    <cc:attribute name="var" />
    <cc:attribute name="value" type="java.util.List"/>
</cc:interface>

<cc:implementation>
    <table data-role="table" data-mode="#{cc.attrs.mode}" id="my-table">
        <thead>
            <tr>
                <ui:repeat value="#{component.getCompositeComponentParent(component).children}" var="child">
                    <th>
                        <h:outputText value="#{child.attrs.header}"/>
                    </th>
                </ui:repeat>
            </tr>
        </thead>
        <tbody>
            <ui:repeat value="#{cc.attrs.value}" var="object">
                <tr>
                    <c:forEach items="#{cc.children}" var="child" varStatus="loop">
                        <cc:insertChildren/>
                    </c:forEach>
                </tr>
            </ui:repeat>
        </tbody>
    </table>
</cc:implementation>
Run Code Online (Sandbox Code Playgroud)

这就是列组合 …

jsf components children nested composite

6
推荐指数
2
解决办法
8129
查看次数

标签 统计

children ×1

components ×1

composite ×1

jsf ×1

nested ×1