In my app if the login is successful in <pm:view id="mobileLogin">
the next view is <pm:view id="mobileTree">
. In the mobileTree view I would like a commandButton to call a logout method that would return the String 'pm:mobileTree?reverse=true'
. The problem is that this is not working. Any ideas?
My Code:
<!-- Login View -->
<pm:view id="mobileLogin">
<pm:header title="LiteDoc" />
<pm:content>
<h:form id="mobileLoginForm">
<p:outputPanel id="container">
<h:panelGroup rendered="#{not loginManager.loggedIn}" >
<p:inputText id="username" value="#{loginManager.username}" />
<p:watermark for="username" value="Login" />
<p:password id="password" value="#{loginManager.password}" />
<p:watermark for="password" value="Senha" />
<p:separator />
<p:commandButton value="Login" icon="refresh" process="@form" update=":mobileTreeForm" action="#{loginManager.loginMobile}" />
</h:panelGroup>
</p:outputPanel>
</h:form>
</pm:content>
</pm:view>
<!-- Tree View -->
<pm:view id="mobileTree">
<pm:header title="LiteDoc">
<!-- Here's the problem --><p:commandButton value="Go" action="pm:mobileLogin?reverse=true" />
</pm:header>
<pm:content>
<h:form id="mobileTreeForm">
<p:dataList value="#{cabinetManager.cabinets}" var="cabinet" rendered="#{loginManager.loggedIn}">
<p:column>
<h:outputText value="#{cabinet.name}" />
</p:column>
</p:dataList>
</h:form>
</pm:content>
</pm:view>
The correct way to execute a method in the server and navigate to other pm:view
is this
<p:commandButton value="Text of the button" actionListener="#{youBean.yourLogOutMehod}" action="pm:theViewYouWantToNavigate" update="theViewYouWantToNavigate" />
Other way that you can navigate in mobile views es is using a header
<pm:view id="youSourceView">
<pm:header title="YourTitleView">
<f:facet name="left"><p:button value="HOME" icon="home" href="#yourHomeViewID?reverse=true"/></f:facet>
<f:facet name="left"><p:button value="BACKVIEW" icon="back" href="#yourBackViewID?reverse=true"/></f:facet>
</pm:header>
<pm:content>
<!-- your content in the view -->
</pm:content>
</pm:view>
You could try to log out in you Bean and do a simple redirect to the /loginPage.jsf it will refresh the url and load by default the first pm:view