Can I determine if a JSF2 facet is defined in a composite component?
Asked Answered
R

1

8

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?

Ricardo answered 24/8, 2012 at 19:50 Comment(0)
A
14

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>
Allantoid answered 25/8, 2012 at 3:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.