Jsf 2 以编程方式获取导航案例<;查看id>;按结果从faces-config.xml

Jsf 2 以编程方式获取导航案例<;查看id>;按结果从faces-config.xml,jsf-2,navigation,faces-config,Jsf 2,Navigation,Faces Config,有没有办法在支持bean中获取导航用例的 假设我想从结果success中获得,它应该是page1.xhtml。有任何辅助功能吗 <navigation-rule> <from-view-id>start.xhtml</from-view-id> <navigation-case> <from-action>#{pageController.processPage1}</from-action>

有没有办法在支持bean中获取导航用例的

假设我想从结果
success
中获得
,它应该是
page1.xhtml
。有任何辅助功能吗

<navigation-rule>
    <from-view-id>start.xhtml</from-view-id>
    <navigation-case>
        <from-action>#{pageController.processPage1}</from-action>
        <from-outcome>success</from-outcome>
        <to-view-id>page1.xhtml</to-view-id>
    </navigation-case>
    <navigation-case>
        <from-action>#{pageController.processPage2}</from-action>
        <from-outcome>success</from-outcome>
        <to-view-id>page2.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>  

start.xhtml
#{pageController.processPage1}
成功
page1.xhtml
#{pageController.processPage2}
成功
page2.xhtml

如果有帮助的话,我使用的是PrettyFaces。

您可以从
配置导航处理程序
获得
导航案例
NavigationCase
表示一个已配置的导航案例,您可以从该对象获取所需的所有信息。注意:

 ConfigurableNavigationHandler configNavHandler = (ConfigurableNavigationHandler)ctxt.getApplication().getNavigationHandler(); //assumes you already have an instance of FacesContext, named ctxt
 NavigationCase navCase = configNavHandler.getNavigationCase(ctxt,null,"success");

 String toViewId = navCase.getToViewId(ctx); // the <to-view-id>
ConfigurableAvigationHandler configNavHandler=(ConfigurableAvigationHandler)ctxt.getApplication().getNavigationHandler()//假设您已经有一个名为ctxt的FacesContext实例
NavigationCase navCase=configNavHandler.getNavigationCase(ctxt,null,“success”);
字符串toViewId=navCase.getToViewId(ctx);//这个