I am creating a JSF2 Facelets composite component. I would like the HTML to render differently if a particular facet is defined. Is there any way to check if a <f:facet name="..." />
has been defined for a composite component?
Yes, you can use UIComponent#getFacets()
to get a mapping of all facets by their name. So all you need to do is to check if the map value is not empty.
<h:panelGroup rendered="#{not empty cc.facets.foo}">
The facet with name "foo" has been definied for this composite!
</h:panelGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With