【问题标题】:ui:define with rendered="false" attribute still renderingui:define with render="false" 属性仍在渲染
【发布时间】:2012-09-21 06:06:51
【问题描述】:
<ui:define name="description" rendered="false">
    <meta name="description" content="do not render" />
</ui:define>

我在我的 xhtml 页面中使用此代码,当我运行应用程序时,元描述仍在呈现。我想根据某些条件使用元描述标签。主布局:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <ui:insert name="description" />
    </h:head>
    ...........
</html>

网页:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"                    
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/masterLayout.xhtml">

    <ui:define name="description" rendered="false">
        <meta name="description" content="do not render" />
    </ui:define>
...........
</ui:composition>

【问题讨论】:

    标签: jsf facelets


    【解决方案1】:

    &lt;ui:define&gt; 是在视图构建期间运行的标记处理程序,而不是在视图渲染期间运行的UIComponent。因此,not 支持 rendered 属性。任何不受支持的属性都会被忽略。

    请改用&lt;ui:fragment&gt;

    <ui:define name="description">
        <ui:fragment rendered="false">
            <meta name="description" content="do not render" />
        </ui:fragment>
    </ui:define>
    

    【讨论】:

      猜你喜欢
      • 2012-11-26
      • 2012-11-20
      • 2011-06-03
      • 1970-01-01
      • 2011-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多