JSF 2.0隐式导航,不同的视图 [英] JSF 2.0 implicit navigation, different views

查看:86
本文介绍了JSF 2.0隐式导航,不同的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关JSF 2.0隐式导航及其如何与视图一起使用的很好的解释.更准确地说,我了解从一种操作方法中,我可以返回一个字符串,该字符串是该操作的结果.如果存在一个JSF视图,其文件名与结果匹配,则这是隐式导航.

I'm looking for a good explanation to JSF 2.0 implicit navigation and how it works with views. To be more precise, I understand that from an action method I can return a string which is the outcome of the action. If there's a JSF view whose file name matches the outcome, then this is implicit navigation.

现在...我的问题是,如果从某个文件夹内的视图中调用该操作,但是要导航至下一个视图的视图位于另一个文件夹中,该怎么办?即,从/manager/edit.xhtml中调用一个动作.该操作应返回什么字符串,以便导航可以安全地转到/user/list.xhtml/index.xhtml/manager/index.xhtml?

Now... my question, what if the action is invoked from a view that's inside a folder but the view that I want to navigate to next is in a different folder? I.e., from /manager/edit.xhtml an action is invoked. What String should that action return so that navigation can safely go to /user/list.xhtml or to /index.xhtml or to /manager/index.xhtml?

推荐答案

据我所知,JSF仅在当前上下文中寻找匹配的视图.您可能必须在faces-config.xml中定义一个导航规则,以特殊方式处理结果.这是一个示例:

As far as my knowledge goes, JSF looks for a matching view only within the current context. You probably have to define a navigation rule in your faces-config.xml to handle an outcome in a special way. Here is an example:

<navigation-rule>
        <from-view-id>/profiles/viewkeypages.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>editkeypage</from-outcome>
            <to-view-id>/users/editkeypage.xhtml</to-view-id>
            <redirect />
        </navigation-case>      
</navigation-rule>

-Praveen.

这篇关于JSF 2.0隐式导航,不同的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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