繁体   English   中英

命令按钮上的JSF导航

[英]JSF navigation on commandbutton

我想有条件地导航到某个页面。 如果某些条件为真,我想导航到其他页面,我希望保持在同一页面上。 我有类似的东西: -

<h:commandButton action="#{bean.navigate}"/>

在bean.navigate我有类似的东西: -

public String navigate(){
    if(value <= 0)
        return "helloWorld";
    else
        return "";
}

但是,如果我返回“”,则抛出错误,并且在h:消息中附加了该页面未找到的消息等。如何避免此错误?

如果要保持同一页面,则需要返回null

你需要像这样的导航规则:

<navigation-rule>
    <from-view-id>/firstpage.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>helloWorld</from-outcome>
        <to-view-id>/successPage.xhtml</to-view-id>
    </navigation-case>
    <navigation-case>
        <to-view-id>/failPage.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM