Cri*_*byJ 6 jsf components children nested composite
我实际上是在尝试创建自定义复合表组件,因为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)
这就是列组合
<cc:interface>
<cc:attribute name="header" />
<cc:attribute name="property" />
<cc:facet name="content"/>
</cc:interface>
<cc:implementation>
<td><cc:insertChildren/></td>
</cc:implementation>
Run Code Online (Sandbox Code Playgroud)
thead独立工作
tbody独立工作
像上面这样把它们放在一起我只能得到它.thead总是留空任何建议?感谢您的提前帮助!
#{cc.children}
这相当于
#{component.getCompositeComponentParent(component).children}
应该两者都可以工作,但由于某种原因无法在某些版本中工作,我想 JSF 的这一部分仍然有一些 bug。
你有没有尝试过
#{cc.getFacets().get('javax.faces.component.COMPOSITE_FACET_NAME').children}
Run Code Online (Sandbox Code Playgroud)
也请参考这个帖子,