jsf – 如何有条件地呈现?

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

内容简介: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


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

查看所有标签

猜你喜欢:

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

Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

Lincoln Stein、Doug MacEachern / O'Reilly Media, Inc. / 1999-03 / USD 39.95

Apache is the most popular Web server on the Internet because it is free, reliable, and extensible. The availability of the source code and the modular design of Apache makes it possible to extend Web......一起来看看 《Writing Apache Modules with Perl and C》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具