ui:定义为rendered ="false"属性仍在渲染 [英] ui:define with rendered="false" attribute still rendering

查看:93
本文介绍了ui:定义为rendered ="false"属性仍在渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

i'm using this code in my xhtml page, when i run the app, meta description is still rendering. i want to use meta description tag depending on some conditions. master layout:

<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>

推荐答案

支持rendered属性.任何不受支持的属性都将被忽略.

The <ui:define> is a taghandler which runs during view build time, not an UIComponent which runs during view render time. It does therefore not support the rendered attribute. Any unsupported attribute is just plain ignored.

改用 <ui:fragment> . /p>

Use <ui:fragment> instead.

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

这篇关于ui:定义为rendered ="false"属性仍在渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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