Use the rendered
attribute. It accepts a boolean expression. Add a method to the User
entity like isAdmin()
or getRole()
and let the rendered
attribute intercept on that.
<h:someComponent rendered="#{user.admin}">
Will be displayed when user.isAdmin() returns true.
</h:someComponent>
<h:someComponent rendered="#{user.role != 'ADMIN'}">
Will be displayed when user.getRole() (String or enum) does not equal ADMIN.
</h:someComponent>
For the case you're interested, here are some more examples how you could use boolean expressions in EL:
<h:someComponent rendered="#{bean.booleanValue}" />
<h:someComponent rendered="#{bean.intValue > 10}" />
<h:someComponent rendered="#{bean.objectValue == null}" />
<h:someComponent rendered="#{bean.stringValue != 'someValue'}" />
<h:someComponent rendered="#{!empty bean.collectionValue}" />
<h:someComponent rendered="#{!bean.booleanValue && bean.intValue != 0}" />
<h:someComponent rendered="#{bean.enumValue == 'ONE' || bean.enumValue == 'TWO'}" />