Query regrading navigation rule in JSF 1.2

南笙酒味 提交于 2019-12-13 07:21:21

问题


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 :

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

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

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

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 ?


回答1:


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

from-view-id: An optional element that contains either a complete page identifier (the context sensitive relative path to the page) or a page identifier prefix ending with the asterisk (*) wildcard character. If you use the wildcard character, the rule applies to all pages that match the wildcard pattern. To make a global rule that applies to all pages, leave this element blank.

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:

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

  • Just don't assign from-view-id and let it work for every view-id you're actually in. You won't have problems while you use different outcomes for each case.


来源:https://stackoverflow.com/questions/14788100/query-regrading-navigation-rule-in-jsf-1-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!