How do I conditionally render an <f:facet>?
jsf, jsf-2, primefaces
Solution
I was able to solve this by swapping the `facet` out for an `attribute`. To summarize:
This works
<p:panel ...>
<f:attribute name="footer" value="#{message}"/>
<!-- ... -->
</p:panel>
But this doesn't work
<p:panel footer="#{message}">
<!-- ... -->
</p:panel>
Neither does this
<p:panel ...>
<f:facet name="footer">#{message}</f:facet>
<!-- ... -->
</p:panel>
Nor this
<p:panel ...>
<f:facet name="footer">
<h:outputText value="#{message}" rendered="#{!empty message}"/>
</f:facet>
<!-- ... -->
</p:panel>
by "works" I mean:
"renders no footer — not just an empty footer — when `#{message}` is empty or `null`; otherwise, correctly renders the footer with the specified text."
PrimeFaces forum thread on this issue
Problem
I would like to be able to conditionally omit a footer from a PrimeFaces panel element: ``` <p:panel header="some text"> <f:facet name="footer"> #{message} </f:facet> <!-- ... --> </p:panel> ``` I hoped that the `rendered` attribute would work: ``` <p:panel header="some text"> <f:facet name="footer" rendered="#{!empty message}"> #{message} </f:facet> <!-- ... --> </p:panel> ``` But the footer is still rendered, with empty content. It appears that `facet` does not have the `rendered` attribute: http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_facet.html. What's the right way to do this?