JSF Tip #62 - Understanding rendered="false"

In JSF you will see people from time to time use rendered="false". But what does it mean?

Well, because in JSF the actual request is page based it builds up a representation of the page when the page gets loaded. When it is building up this representation it builds up the entire page, even the parts that are not going to be rendered.

Eg.


    ...
    <h:body>
        <h:outputText id="id1" rendered="true" value="2"/> 
        <h:outputText id="id2" rendered="false" value="3"/> 
    </h:body>
    ...

        

So for the above page snippet it will have 2 output texts in the component tree, but when it is rendered you will only see the following


    2
        

If you want the page to not put it into the component tree altogether you will need to use the c:if tag that allows you to dynamically pick and choose what gets included in the component tree.

Posted June 3, 2014

Up