Javascript JSF和Primefaces条件导航

Javascript JSF和Primefaces条件导航,javascript,jsf,primefaces,navigation,Javascript,Jsf,Primefaces,Navigation,我正在使用JSF2.2和primefaces开发一个web应用程序。我想根据用户选择的不同选项转到一个或另一个页面。如果用户选择控制台PS4,伦敦金融城转到page1.xhtml,如果用户选择控制台xbox,巴黎金融城转到page2.xhtml,我该怎么办 代码如下: <h:form> <h3 style="margin-top:0">Basic</h3> <h:panelGrid columns="2" style="margin-bo

我正在使用JSF2.2和primefaces开发一个web应用程序。我想根据用户选择的不同选项转到一个或另一个页面。如果用户选择控制台PS4,伦敦金融城转到page1.xhtml,如果用户选择控制台xbox,巴黎金融城转到page2.xhtml,我该怎么办

代码如下:

<h:form>
    <h3 style="margin-top:0">Basic</h3>
    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
        <p:outputLabel for="console" value="Console:" />
        <p:selectOneRadio id="console" value="#{radioView.console}">
            <f:selectItem itemLabel="Xbox One" itemValue="Xbox One" />
            <f:selectItem itemLabel="PS4" itemValue="PS+" />
            <f:selectItem itemLabel="Wii U" itemValue="Wii U" />
        </p:selectOneRadio>
    </h:panelGrid>

  <h3 style="margin-top:0">Basic</h3>
    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
        <p:outputLabel for="city" value="city:" />
        <p:selectOneRadio id="city" value="#{radioView.city}">
            <f:selectItem itemLabel="London" itemValue="london" />
            <f:selectItem itemLabel="Paris" itemValue="paris" />
            <f:selectItem itemLabel="NY" itemValue=ny" />
        </p:selectOneRadio>
    </h:panelGrid>

基本的
基本的

例如,您可以使用
操作(在
中)创建一个
命令按钮
。根据属性
控制台
城市
的值,从该操作返回“page1.xhtml”或“page2.xhtml”

例如(未经测试):


公共字符串gotoNextPage(){
if(“PS4.equals(console)&&“london.equals(city))//它有值“PS+”,但我认为这是一个错误
返回“page1.xhtml”;
否则如果(“Xbox One.equals(控制台)&“paris.equals(城市))
返回“page2.xhtml”;
否则,如果。。。。。。。。
}

谢谢,但它不起作用。我做错了什么事。在托管bean中,选项应该像公共字符串一样声明,对吗?
<p:commandButton value="Go!" action="#{radioView.gotoNextPage}" />

public String gotoNextPage() {
    if ("PS4".equals(console) && "london".equals(city)) // It has value "PS+" but I expect it's an error
        return "page1.xhtml";
    else if ("Xbox One".equals(console) && "paris".equals(city))
        return "page2.xhtml";
    else if ........
}