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 Migrating from JSF 1.2 to JSF 2.0 as a guide.
The project used some tag library called htmLib
with the namespace http://jsftutorials.net/htmLib
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 <div>
or <table>
in JSP pages.
Since plain HTML tags can now be used in XML Facelets with JSF2, I am right now removing all occurences of tags from the htmLib
taglib like <htm:div>...</htm:div>
and replace them with plain HTML tags like <div>...</div>
.
However, some of the tags used from htmLib
contain the render
attribute for conditional rendering, like this:
<htmLib:h4 render="someCondition">
...
</htmLib:h4>
Because plain HTML tags don't have a render
attribute for this purpose, I was searching for an alternative way to conditionally render plain HTML tags and stumbled upon this answer on SO: How to conditionally render plain HTML elements like <div>s?
So, my idea is to replace a construct like the one above with something like
<ui:fragment render="someCondition">
<h4>
...
</h4>
</ui:fragment>
My questions:
- Is wrapping HTML tags inside a
<ui:fragment>
tag with therender
attribute the recommended way to conditionally render HTML tags, or is this method only valid and recommended for the case in the linked question? - Are there other ways to conditionally render plain HTML tags in Facelets that should be preferred?
- Does the
<ui:fragment>
wrapping method work, no matter what kind of plain HTML is contained within it? - Can conditionally rendered
<ui:fragment>
blocks be nested?