title: Should I use ui:fragment with the render attribute to conditionally render HTML tags in Facelets with JSF 2.2?
body: <p>I am in the process of upgrading an old project from JSF 1.1 to JSF 2.2. Specifically, I am upgrading the JSF implementation from MyFaces 1.1 to MyFaces 2.2.12, replacing JSPs with Facelets and upgrading/replacing outdated tag libraries. I am mainly using <a href="https://stackoverflow.com/questions/4441713/migrating-from-jsf-1-2-to-jsf-2-0">Migrating from JSF 1.2 to JSF 2.0</a> as a guide. </p>
  
  <p>The project used some tag library called <code>htmLib</code> with the namespace <code>http://jsftutorials.net/htmLib</code> in it's JSP pages. I can't find any documentation about this tag library anymore, neither on the jsftutorials webpage nor elsewhere, but apparently it was used to include plain HTML tags like <code>&lt;div&gt;</code> or <code>&lt;table&gt;</code> in JSP pages.</p>
  
  <p>Since plain HTML tags can now be used in XML Facelets with JSF2, I am right now removing all occurences of tags from the <code>htmLib</code> taglib like <code>&lt;htm:div&gt;...&lt;/htm:div&gt;</code> and replace them with plain HTML tags like <code>&lt;div&gt;...&lt;/div&gt;</code>. </p>
  
  <p>However, some of the tags used from <code>htmLib</code> contain the <code>render</code> attribute for conditional rendering, like this:</p>
  
  <pre><code>&lt;htmLib:h4 render="someCondition"&gt;
     ...
  &lt;/htmLib:h4&gt;
  </code></pre>
  
  <p>Because plain HTML tags don't have a <code>render</code> attribute for this purpose, I was searching for an alternative way to conditionally render plain HTML tags and stumbled upon this answer on SO: <a href="https://stackoverflow.com/questions/8816212/how-to-conditionally-render-plain-html-elements-like-divs">How to conditionally render plain HTML elements like &lt;div&gt;s?</a></p>
  
  <p>So, my idea is to replace a construct like the one above with something like</p>
  
  <pre><code>&lt;ui:fragment render="someCondition"&gt;
     &lt;h4&gt;
        ...
     &lt;/h4&gt;
  &lt;/ui:fragment&gt;
  </code></pre>
  
  <p>My questions: </p>
  
  <ul>
  <li>Is wrapping HTML tags inside a <code>&lt;ui:fragment&gt;</code> tag with the <code>render</code>
  attribute the recommended way to conditionally render HTML tags, or
  is this method only valid and recommended for the case in the linked question?  </li>
  <li>Are there other ways to conditionally render plain HTML tags in Facelets that should be preferred?</li>
  <li>Does the <code>&lt;ui:fragment&gt;</code> wrapping method work, no matter what kind of plain HTML is contained within it?</li>
  <li>Can conditionally rendered <code>&lt;ui:fragment&gt;</code> blocks be nested?</li>
  </ul>