以结果</to-view-id>从faces-config.xml以编程方式获取导航大小写<to-view-id>

时间:2015-03-12 13:25:15

标签: jsf-2 navigation faces-config

有没有办法在支持bean中获取导航案例的<to-view-id>

我想说我想从结果<to-view-id>获得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>  

如果有帮助,我会使用PrettyFaces。

1 个答案:

答案 0 :(得分:6)

您可以从NavigationCase获得ConfigurableNavigationHandlerNavigationCase表示已配置的导航案例,您可以从此对象获取所需的所有信息。观察:

 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>