Reputation: 421
I currently use
and tried to put a composite component within a composite component.
Composite component:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:p="http://primefaces.org/ui"
xmlns:components="http://java.sun.com/jsf/composite/components">
<composite:interface>
<composite:attribute name="myobject" required="true" />
</composite:interface>
<composite:implementation>
<p:panelGrid id="container">
<components:newEntry outputLabelId="labelId" outputLabelValue="#{msgs.label}"
selectOneMenuId="labelMenuId" selectOneMenuValue="#{myobject.value}"
selectOneMenuItems="#{myobject.values}" update=":targets">
</components:newEntry>
</p:panelGrid>
</composite:implementation>
</html>
Nested composite component:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:p="http://primefaces.org/ui"
xmlns:components="http://java.sun.com/jsf/composite/components">
<composite:interface>
<composite:attribute name="outputLabelId" required="true" />
<composite:attribute name="outputLabelValue" required="true" />
<composite:attribute name="selectOneMenuId" required="true" />
<composite:attribute name="selectOneMenuValue" required="true" />
<composite:attribute name="selectOneMenuItems" required="true" />
<composite:attribute name="update" required="true" />
<composite:attribute name="rendered" default="true" />
</composite:interface>
<composite:implementation>
<p:row>
<p:column>
<p:outputLabel id="#{cc.attrs.outputLabelId}" value="#{cc.attrs.outputLabelValue}"
rendered="#{cc.attrs.rendered}" />
</p:column>
<p:column>
<p:selectOneMenu id="#{cc.attrs.selectOneMenuId}" value="#{cc.attrs.selectOneMenuValue}"
effect="none" filter="true" filterMatchMode="contains" rendered="#{cc.attrs.rendered}">
<f:selectItems value="#{cc.attrs.selectOneMenuItems}" />
<p:ajax event="change" update="#{cc.attrs.update}" />
</p:selectOneMenu>
</p:column>
</p:row>
</composite:implementation>
</html>
However I don't get an error message or a rendered element which is quite confusing.
Only when I move the nested component on the same level as its parent, is the nested component rendered.
Is this not supported in 2.1.6 or am I doing something wrong?
Upvotes: 2
Views: 3576
Reputation: 421
I just remembered that I had similiar problem earlier with the prime faces panelGrid. Somehow the panelGrid doesn't accept a nested component and just swallows it without an error or warning.
Replacing the prime faces panelGrid with a JSF one solves this problem:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:p="http://primefaces.org/ui"
xmlns:components="http://java.sun.com/jsf/composite/components">
<composite:interface>
<composite:attribute name="myobject" required="true" />
</composite:interface>
<composite:implementation>
<h:panelGrid id="container">
<components:newEntry outputLabelId="labelId" outputLabelValue="#{msgs.label}"
selectOneMenuId="labelMenuId" selectOneMenuValue="#{myobject.value}"
selectOneMenuItems="#{myobject.values}" update=":targets">
</components:newEntry>
</h:panelGrid>
</composite:implementation>
</html>
I tested Prime faces 5.0 due to the JSF 2.3 dependency. In that version the problem was still present.
Upvotes: 2