I have something like this:
<ul>
<li>User</li>
<li>Admin</li>
..
</ul>
and want to render the list-item 'Admin' only if the actual User is in Role 'Admin'.
I know, I can do that like this:
<ul>
<li>User</li>
<h:panelGroup rendered="#{request.isUserInRole('admin')}">
<li>Admin</li>
</h:panelGroup>
..
</ul>
However the markup inserts a "span"-element because of h:panelGroup.
Is there a JSF-Component with a 'rendered'-property which does not insert any html?
Unfortunately, Facelets ui:remove/ui:include has not a 'rendered' property:
<ul>
<li>User</li>
<ui:remove rendered="#{request.isUserInRole('admin')}">
<li>Admin</li>
</ui:remove>
..
</ul>
How should I solve such a scenario?
What you mean can be achieved by using ui:fragment.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:fragment rendered="#{action.isUserLoggedIn()}">
<!-- this will only be shown to logged in users -->
</ui:fragment>
</ui:composition>