How to hide elements in JSF?

You could just do this:

<div style="display:#{yourBean.property}"></div>

Where yourBean.property would return 'none' to hide the div


first of all you should not wrap your elements with h:gridPanel which results in html table

instead you should wrap with h:panelGroup which results in span in html code , you can also add layout="block" to h:panelGroup to make it rendered as div

second you dont not use jstl when hiding div instead do something like this

<div style="display:#{(myBean.hideSomeDiv)?'none':'block'}">My Div Content</div>

or

<h:panelGroup styleClass="#{(myBean.hideSomeDiv)?'hide':''">My Span Content</h:panelGroup>

where in css file add this :

.hide { 
    display: none;
}

INMO you always better hide in JSF with rendered="#{myBean.renderCondition}"

Take a look at BalusC over here Conditionally displaying JSF components

Tags:

Jsf