using insertChildren AND getting child attributes
children, components, composite, jsf, nested
Solution
This is not a bug, it actually works as designed in mojarra. Using cc:insertChildren moves the children to the parent tag of the cc:insertChildren tag. This problem is equivalent to another problem and has the same solution. See my answer to this question.
Basically, you put a `<ui:fragment>` around the `<cc:insertChildren>`, bind that fragment to a property in a FacesComponent bean.
Problem
I am actually trying to create a custom composite table component because h:datatable or p:datatable do not fit my needs. Nevertheless it shall be used like a primefaces datatable. After I found JSF composite component childrens and Expose items of a list while iterating within composite component I saw the finish line, but now I got stuck. My 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> ``` And this is the datatable composite: ``` <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> ``` And that's the column composite ``` <cc:interface> <cc:attribute name="header" /> <cc:attribute name="property" /> <cc:facet name="content"/> </cc:interface> <cc:implementation> <td><cc:insertChildren/></td> </cc:implementation> ``` thead works standalone tbody works standalone Putting them together like above I only get tbody. thead always stays empty Any suggestions? Thanks for your help in Advance!