以编程方式获取导航案例< to-view-id>从faces-config.xml按结果 [英] Programmatically get navigation case <to-view-id> from faces-config.xml by outcome

查看:128
本文介绍了以编程方式获取导航案例< to-view-id>从faces-config.xml按结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在后备bean中获得导航包的<to-view-id>吗?

Is there any way to get the <to-view-id> of a navigation case in the backing bean?

假设我要从结果success中获取<to-view-id>,该结果应该为page1.xhtml.有帮助功能吗?

Let's say I want to get the <to-view-id> from the outcome success, which is supposed to be page1.xhtml. Is there any helper function?

<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.

If it helps, I'm using PrettyFaces.

推荐答案

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

You can get a NavigationCase, from a ConfigurableNavigationHandler. The NavigationCase represents a configured navigation case and you can get all the info you need from this object. Observe:

 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>

这篇关于以编程方式获取导航案例&lt; to-view-id&gt;从faces-config.xml按结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆