2016-10-05 85 views
0

该场景是一个使用JSF和Primeface Mobile开发的移动页面。 我想在多个页面之间的同一个xhtml页面中导航。当我点击主页面中的一个按钮时,内容必须从第二页的托管bean中加载。我跟着这个例子http://www.primefaces.org/showcase/mobile/navigation.xhtml,但我不能导航,我有'viewId mobile.xhtml,行动#{myManagedBean.gotoSecond}和结果下午:第二'没有导航情况下匹配的消息。 这里的XHTML代码JSF Primefaces Mobile导航

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:pm="http://primefaces.org/mobile"> 

    <f:view renderKitId="PRIMEFACES_MOBILE" /> 

    <h:head> 
    </h:head> 

    <h:body> 

     <pm:page id="first"> 
     <pm:header title="Page 1"></pm:header> 

     <pm:content> 
      <h:form> 
       <p:commandButton value="Ajax Action" action="#{myManagedBean.gotoSecond}"/> 

      </h:form> 
     </pm:content> 
     </pm:page> 

     <pm:page id="second"> 
     <pm:header title="Page 2"></pm:header> 

     <pm:content> 
      <p>Page 2 content.</p> 
      <p:button outcome="pm:first" value="Go Back" /> 

      <h:form> 
       #{myManagedBean.hello} 
      </h:form> 

     </pm:content> 
     </pm:page> 

    </h:body> 

    </html> 

和托管bean方法

public String gotoSecond(){ 
    return "pm:second"; 
} 

回答

0

你需要这个在你的脸上的配置文件:

<application> 
    <navigation-handler> 
     org.primefaces.mobile.application.MobileNavigationHandler 
    </navigation-handler> 
</application>