Jsf 导航p:commandButton Primefaces Mobile

Jsf 导航p:commandButton Primefaces Mobile,jsf,primefaces,primefaces-mobile,Jsf,Primefaces,Primefaces Mobile,在我的应用程序中,如果在中成功登录,则下一个视图为。在mobileTree视图中,我希望commandButton调用注销方法,该方法将返回字符串“pm:mobileTree?reverse=true”。问题是这不起作用。有什么想法吗 我的代码: <!-- Login View --> <pm:view id="mobileLogin"> <pm:header title="LiteDoc" /> <pm:co

在我的应用程序中,如果在
中成功登录,则下一个视图为
。在mobileTree视图中,我希望commandButton调用注销方法,该方法将返回字符串“
pm:mobileTree?reverse=true”
。问题是这不起作用。有什么想法吗

我的代码:

 <!-- 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>

在服务器中执行方法并导航到其他
pm:view
的正确方法是

 <p:commandButton value="Text of the button" actionListener="#{youBean.yourLogOutMehod}" action="pm:theViewYouWantToNavigate" update="theViewYouWantToNavigate" />

在移动视图中导航的另一种方式是使用标题

<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> 


您可以尝试注销您的Bean并简单重定向到/loginPage.jsf,它将刷新url并默认加载第一个
pm:view

,如PrimeFaces移动手册(第12页)中所述,如果您想调用服务器操作,然后导航到id为
myViewId
pm:view
,您必须执行以下操作:

<p:commandButton value="Logout" oncomplete="PrimeFaces.navigate('#myViewId', {reverse : 'true'})" action="#{loginBean.logout}" />

您是否尝试过提供的解决方案?别忘了接受(大多数)有帮助的答案