jsf – 如何有条件地呈现?

栏目: Java · 发布时间: 8年前

内容简介:http://stackoverflow.com/questions/4369114/how-do-i-conditionally-render-an-ffacet

我希望能够从PrimeFaces面板元素有条件地省略页脚:

<p:panel header="some text">
    <f:facet name="footer">
        #{message}
    </f:facet>
    <!-- ... -->
</p:panel>

我希望渲染的属性可以工作:

<p:panel header="some text">
    <f:facet name="footer" rendered="#{!empty message}">
        #{message}
    </f:facet>
    <!-- ... -->
</p:panel>

但页脚仍然呈现,内容空白.看来facet没有渲染属性: http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_facet.html .

这样做的正确方法是什么?

我能够通过交换一个属性来解决这个问题.总结:

这个工作

<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时,不会显示页脚 – 而不仅仅是一个空的页脚,否则,使用指定的文本正确地呈现页脚.

PrimeFaces forum thread on this issue

http://stackoverflow.com/questions/4369114/how-do-i-conditionally-render-an-ffacet


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

Bandit Algorithms for Website Optimization

Bandit Algorithms for Website Optimization

John Myles White / O'Reilly Media / 2013-1-3 / USD 19.99

This book shows you how to run experiments on your website using A/B testing - and then takes you a huge step further by introducing you to bandit algorithms for website optimization. Author John Myle......一起来看看 《Bandit Algorithms for Website Optimization》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具