tags:

views:

46

answers:

2

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?

+2  A: 

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)

Odelya
thanks for answering, and what tag should I use when I'm just embracing some html code which naturally doesn't have rendered attribute?
coubeatczech
The JSF one of course :)
BalusC
A: 
<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>.

amorfis
He want to **conditionally** hide content.
BalusC
coubeatczech
You could try `<ui:fragment>`. It does not support `rendered` attribute but... it works.
amorfis