Reputation: 31
I've two nested composite
Composite A
<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
</composite:interface>
<composite:implementation>
<composite:insertChildren />
<p:separator />
</composite:implementation>
</ui:composition>
and composite B
(CASE #1)
<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
xmlns:mycomposites="http://java.sun.com/jsf/composite/mycomposites"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
</composite:interface>
<composite:implementation>
<mycomposites:a>
<composite:insertChildren />
</mycomposites:a>
</composite:implementation>
</ui:composition>
Finally I have my view or page
<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
xmlns:gt="http://java.sun.com/jsf/composite/template"
xmlns:mycomposites="http://java.sun.com/jsf/composite/mycomposites"
template="/template/template.xhtml">
<ui:define name="body">
<mycomposites:b>
<h:outputText value="test" />
</mycomposites:b>
</ui:define>
</ui:composition>
"test" is not rendered.
For what I've seen this is because insertChildren
in B is inside another composite insertChildren
(A).
If I move insertChildren
in B outside the composite works fine like so:
(CASE #2)
<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://sig.com/faces"
xmlns:mycomposites="http://java.sun.com/jsf/composite/mycomposites"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
</composite:interface>
<composite:implementation>
<mycomposites:desktop>
<!-- MOVED -->
</mycomposites:desktop>
<composite:insertChildren />
</composite:implementation>
</ui:composition>
But CASE #2 doesn't do much for me. I need it like CASE #2
Any help?
Thank you
Upvotes: 2
Views: 841
Reputation: 86
I had the same problem like you.
I have a component A.xhtml
<composite:implementation>
<primefaces:datatable>
<primefaces:column>
<h:outputText value="#{row.identityName}" />
</primefaces:column>
<composite:insertChildren />
</primefaces:datatable>
</composite:implementation>
which is used in three files:
In the "identity/*/search.xhtml" pages i give many identitcal attributes and children to the component A. Because this produces much duplicated code i tried to make s sub component of component A for the two identity pages.
identity_A.xhtml
<composite:implementation>
<component:A identityAttribute="example">
<primefaces:column>
<h:outputText value="#{row.identityName}" />
</primefaces:column>
<composite:insertChildren />
</component:A>
</composite:implementation>
I noticed, that the children, which i gave to identity_A.xhtml arent any longer displayed in the primefaces datatable.
My Solution/Workaround for this Problem was to create a template for this two pages instead of a sub-component:
identitySearch.xhtml
...
<component:A identityAttribute="example">
<primefaces:column>
<h:outputText value="#{row.identityName}" />
</primefaces:column>
<ui:insert name="datatableChildren">
</component:A>
...
Perhaps you can solve your Problem the way i did.
I hope, that there will be a solution, to use composite:insertChildren
in nested composite components.
Upvotes: 1