【问题标题】:jsf h:selectOneMenu : redirecting to new pagejsf h:selectOneMenu : 重定向到新页面
【发布时间】:2011-10-15 08:26:15
【问题描述】:

我正在使用 spring3.0、jsf 2.0 和richfaces。 我的 Bean 中有以下方法:

public String onChange (){
    String render; 
    if  (this.getItemValue().equals("project")){        
        render = "Page1"; 
    } else if (this.getItemValue().equals("version")){
        render = "Page2"; 
    } 
    return render; 
}

在我的 xhtml 页面中有一个“h:selectOneMenu”

<h:selectOneMenu value="#{Action.itemValue}" onchange="submit()"
 style="width: 90px; height: 22px">
    <f:selectItem itemLabel="#{msg.menu_project}" itemValue="project" />
    <f:selectItem itemLabel="Version" itemValue="version" />
    <a4j:support event="onchange" action="#{Action.onChange}"/>
</h:selectOneMenu>

我想在我的组合框列表中选择一个选项以重定向到另一个页面。 在调试的时候,我检查了onChange方法执行得很好,但是新页面没有渲染!!

谁能给我任何建议。谢谢

【问题讨论】:

    标签: spring jsf-2


    【解决方案1】:

    如果您想根据 ajax 请求导航,则需要发送重定向。

    return render + "?faces-redirect=true";
    

    请注意,您的 onchange="submit()" 是多余的。去掉它。 &lt;a4j:support&gt; 已经这样做了。

    【讨论】:

    • 谢谢您的回复,我试过了,但没有解决我的问题。方法已执行,但页面未呈现。
    猜你喜欢
    • 1970-01-01
    • 2012-03-16
    • 2013-11-26
    • 1970-01-01
    • 1970-01-01
    • 2012-03-04
    • 1970-01-01
    • 2021-04-05
    相关资源
    最近更新 更多