I create a composition template:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cs="http://java.sun.com/jsf/composite/composite">
<h:panelGroup rendered="#{not empty userc.userb.user.id}">
<h:panelGrid columns="3">
<h:outputText value="Welcome, " />
<h:outputLink value="profile.xhtml">
<h:outputText value="#{userc.personb.person.name}" />
</h:outputLink>
<h:form>
<h:commandLink action="#{userc.logout}">Log out</h:commandLink>
</h:form>
</h:panelGrid>
</h:panelGroup>
<h:panelGroup rendered="#{empty userc.userb.user.id}">
<h:outputLink value="pages/login.xhtml">Login</h:outputLink>
</h:panelGroup>
</ui:composition>
My intention is to hide the first panelGroup if the user is not logged, if he does then I hide the second panelGroup then show the first one.
I’m trying do this but doesn’t work.
Any idea ?
Without login:

After login:
with login http://img89.imageshack.us/img89/9866/0602nov.jpg
In your
entity.Userclass, replaceby
This way it will default to
nullinstead of0and thus#{empty userc.userb.user.id}will betrue. The common practice is anyway to use wrappers instead of primitives in entity’s properties.