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?
Can I determine if a JSF2 facet is defined in 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>
© 2022 - 2024 — McMap. All rights reserved.