ui:define with rendered="false" attribute still rendering
Asked Answered
B

1

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

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>

web page:

<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>
Bashee answered 29/9, 2012 at 18:54 Comment(0)
D
17

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.

Use <ui:fragment> instead.

<ui:define name="description">
    <ui:fragment rendered="false">
        <meta name="description" content="do not render" />
    </ui:fragment>
</ui:define>
Dismissive answered 29/9, 2012 at 21:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.