有条件地显示纯 HTML 元素 [英] Conditionally display pure HTML elements

查看:36
本文介绍了有条件地显示纯 HTML 元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有条件地显示以下元素:

I would like to conditionally display the following elements:

<li>
  <h:link outcome="mypage" value="My Value" />
</li>

所以我的条件应该确定 <li> 标签和它的所有子标签是否会被显示.AFAIK,我不能使用 因为

  • 标签内的 UIComponent (代码>).

    So my condition should determine if the <li> tag and all it's children would be displayed or not. AFAIK, I can't use <f:verbatim> because of the UIComponent inside the <li> tag (<h:link>).

    有什么想法吗?

    推荐答案

    不使用 的另一个原因:它在 JSF 2.0 中被弃用.

    There's another reason to not use <f:verbatim>: it's deprecated in JSF 2.0.

    使用.它在语义上比 <h:panelGroup>(当没有指定客户端特定属性时它本身确实不呈现任何内容)更正确,并且开销也更少.

    Use <ui:fragment>. It's semantically more correct than a <h:panelGroup> (which by itself indeed renders nothing when no client side specific attributes are specified) and has also a bit less overhead.

    <ui:fragment rendered="#{bean.show}">
        ...
    </ui:fragment>
    

    (注意:由于一些错误,Netbeans 似乎混蛋不支持此属性,但这是不正确的,它肯定支持)

    这篇关于有条件地显示纯 HTML 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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