有没有办法在支持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。
答案 0 :(得分:6)
您可以从NavigationCase
获得ConfigurableNavigationHandler
。 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>