The basic expression you're after is the following:
#{cc.childCount}
or more elaborately:
#{component.getCompositeComponentParent(component).childCount}
E.g. the following composite component:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cc="http://java.sun.com/jsf/composite"
>
<cc:interface/>
<cc:implementation>
<h:outputText value="Children: #{cc.childCount}" />
</cc:implementation>
</html>
used on the following Facelet:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:test="http://java.sun.com/jsf/composite/test"
>
<h:body>
<test:myCom>
<h:outputText value="first child" />
<h:outputText value="second child" />
</test:myCom>
</h:body>
</html>
will print Children: 2
.
Thus #{cc.childCount != 0}
will tell you whether a composite component has children or not.
cc.childCount
only gives you the right answer, if you don't use<composite:insertChildren />
on the composite implementation. – Porphyrin