When I want to hide some content in JSF, what tag is made for this purpose? There are several tags that can do the job:
<f:subview rendered="#{...condition...}" />
and
<c:when test="#{...conditon...}" />
Which is the right one to use?
When I want to hide some content in JSF, what tag is made for this purpose? There are several tags that can do the job:
<f:subview rendered="#{...condition...}" />
and
<c:when test="#{...conditon...}" />
Which is the right one to use?
in JSF, using rendered
is the best approach.
Using JSTL tags like <c:when>
, is not recommended at all, and even break some functunality of JSF like ViewScope annotation. Always try to use JSF tags (like ui:repeat
instead of c:forEach
)
<ui:remove>
Look here: http://www.jsftoolbox.com/documentation/facelets/10-TagReference/facelets-ui-remove.html
UPDATE
If you want to conditionally hide some content, you can use
<h:panelGroup rendered="#{...condition...}">
It renders as <span>
, you can also add attribute layout="block"
<h:panelGroup rendered="#{...condition...}" layout="block">
to render it as <div>
.