本文介绍了JSF 1.2中的查询重排导航规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我具有以下导航规则:

If I have below navigation rule :

<navigation-rule>
    <from-view-id>Mainview</from-view-id>
    <navigation-case>
        <from-outcome>outcome1</from-outcome>
        <to-view-id>view1</to-view-id>  
    </navigation-case>
    <navigation-case>
        <from-outcome>outcome2</from-outcome>
        <to-view-id>view2</to-view-id>  
        <redirect/>         
    </navigation-case>
    <navigation-case>
        <from-outcome>outcome3</from-outcome>
        <to-view-id>view3</to-view-id>  
        <redirect/>         
    </navigation-case>
</navigation-rule>

如果整个流程没有任何验证错误,那么一切都会正常进行.那是:

If there is no any validation error for this entire flow , everything will work fine. That is :

步骤1)MainForm中的方法返回result1渲染view1 步骤2)视图1中的方法返回渲染视图2的结果步骤3)view2中的方法返回结果3渲染view3

Step 1)Method from MainForm returns outcome1 rendering view1 Step 2)Method from view1 returns outcome2 rendering view2 Step 3)Method from view2 returns outcome3 rendering view3

请注意,以上规则中没有重定向,这意味着浏览器将在浏览器窗口中显示Mainview.

Please note that there is no redirect in above rule , meaning browser will have Mainview displayed in browser window.

如果在上面的步骤2中,验证失败,则浏览器将在地址栏中显示view1,而不是显示view2.

If at step 2 above , validation fails , then instead of showing view2 , browser will have view1 shown in the address bar.

现在,对于下一个流程(一旦验证成功),起点将不是Mainview,但是view1意味着必须编写导航用例 带有view1

Now , for the next flow (once validation succeeds), starting point won't be Mainview but view1 meaning navigation cases will have to be written with view1

如何处理?我们是否需要编写另一套导航规则?还是像上面那样设计导航规则是错误的?

How can this be handled ? Do we need to write another set of navigation-rules ? Or designing navigation-rule like above is plain wrong ?

推荐答案

查看规范,我们必须得出结论,每个<navigation-rule>中只能有一个<from-view-id>标记.

Looking at the specification, we must conclude there can only be one <from-view-id> tag into each <navigation-rule>.

此标签为可选标签,您可以指定是否指定-请注意,您还可以指定通配符视图ID,因此导航案例涵盖与模式相关的每个视图ID-但每个规则只能有一个.因此,对于您的情况,您有以下选择:

Being this tag optional, you can specify it or not -note that you can also specify a wildcard view id, so the navigation case covers every view id's that are related with the pattern- but you only can have one for each rule.So for your case you have the following options:

  • 创建一个新的导航规则以管理从view1开始的导航案例.
  • 使用某种模式覆盖您的视图ID,并使用通配符对其进行分组(将您的第一页命名为 view0 ):

  • Create a new navigation rule to manage navigation cases starting from view1.
  • Cover your view id's with a pattern and use a wildcard to group them (naming your first page view0):

<navigation-rule>
     <from-view-id>view*</from-view-id>
     <navigation-case>
     <from-outcome>outcome1</from-outcome>
     <to-view-id>view1</to-view-id>  
</navigation-case>
<navigation-case>
    <from-outcome>outcome2</from-outcome>
    <to-view-id>view2</to-view-id>  
    <redirect/>         
</navigation-case>
<navigation-case>
    <from-outcome>outcome3</from-outcome>
    <to-view-id>view3</to-view-id>  
    <redirect/>         
</navigation-case>

这篇关于JSF 1.2中的查询重排导航规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 20:56