Using insertChildren And Getting Child Attributes

I'm actually trying to create a custom table component because h: datatable or p: datatable do not fit my needs. However, it should be used as data streams. After I found the children of the composite JSF components and also Expose list items when repeating in the composite component I saw the finish line, but now I'm 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 a 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 compound columns

<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 offline

tbody works autonomously

, , . thead ? Advance!

+5
4

, , mojarra. cc: insertChildren cc: insertChildren. . . .

, <ui:fragment> <cc:insertChildren>, FacesComponent bean.

+4

#{cc.children}, #{component.getCompositeComponentParent(component).children} - , , JSF - .

 #{cc.getFacets().get('javax.faces.component.COMPOSITE_FACET_NAME').children}

. ,

JSF2, , ?

+1

. renderFacet insertChildren.

, : #{cc.facets.yourFacetName.children} , : <composite:renderFacet name="yourFacetName"/>.

+1

I found iterating over children and using <composite:insertChildren />in the same component is almost impossible. At least in the implementation of Mojarra 2.2.6.

An intermediate facet approach did not work for me either.

In the end, I decided:

  • save the child component (tab) as is
  • remove all code from composition: implementation of component parent (tab group)
  • implement encodeAll()in the faces component corresponding to the parent component

This question is older than a year. Please share if there will be a simpler solution.

+1
source

All Articles