Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 952
Shadowman Avatar asked Aug 24 '12 19:08

Shadowman


1 Answers

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>
like image 101
BalusC Avatar answered Nov 18 '22 22:11

BalusC