如何有条件地渲染< f:facet&gt ;? [英] How do I conditionally render an <f:facet>?

查看:103
本文介绍了如何有条件地渲染< f:facet&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够有条件地从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."

PrimeFaces论坛主题

这篇关于如何有条件地渲染&lt; f:facet&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆