如何有条件地渲染< f:facet> ;? [英] How do I conditionally render an <f:facet>?
问题描述
我希望能够有条件地从PrimeFaces面板元素中省略页脚:
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>
我希望rendered
属性能起作用:
<p:panel header="some text">
<f:facet name="footer" rendered="#{!empty message}">
#{message}
</f:facet>
<!-- ... -->
</p:panel>
但是页脚仍然呈现,内容为空.似乎facet
没有rendered
属性: http://www .jsftoolbox.com/documentation/help/12-TagReference/core/f_facet.html .
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.
什么是正确的方法?
推荐答案
我能够通过将facet
换成attribute
来解决此问题.总结一下:
I was able to solve this by swapping the facet
out for an attribute
. To summarize:
<p:panel ...>
<f:attribute name="footer" value="#{message}"/>
<!-- ... -->
</p:panel>
但这不起作用
<p:panel footer="#{message}">
<!-- ... -->
</p:panel>
也不是
<p:panel ...>
<f:facet name="footer">#{message}</f:facet>
<!-- ... -->
</p:panel>
也不是
<p:panel ...>
<f:facet name="footer">
<h:outputText value="#{message}" rendered="#{!empty message}"/>
</f:facet>
<!-- ... -->
</p:panel>
工作"是指:
在#{message}
为空或null
时,提供否页脚—不仅是空白页脚&mdash ;,否则,将正确显示具有指定文本的页脚."
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."
这篇关于如何有条件地渲染< f:facet> ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!