[ http://issues.apache.org/jira/browse/MYFACES-1340?page=all ]

Erik Gustavson updated MYFACES-1340:
------------------------------------

    Status: Patch Available  (was: Open)

> wildcard navrule bug in NavigationHandlerImpl
> ---------------------------------------------
>
>          Key: MYFACES-1340
>          URL: http://issues.apache.org/jira/browse/MYFACES-1340
>      Project: MyFaces Core
>         Type: Bug

>   Components: JSR-127
>     Versions: 1.1.4-SNAPSHOT
>  Environment: JBoss 4.x / Tomcat 5.5 / JDK5
>     Reporter: Erik Gustavson
>  Attachments: patchfile.txt
>
> I think a subtle logic bug crept into NavigationHandlerImpl handling on 
> wildcard matches during this revision:
> http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java?r1=410138&r2=414102&diff_format=h
> Here is the scenario:
> there are two navigation rules:
>     <navigation-rule>
>         <from-view-id>/foo.jsp</from-view-id>
>         <navigation-case>
>             <from-outcome>success</from-outcome>
>             <to-view-id>/bar.jsp</to-view-id>
>         </navigation-case>
>     </navigation-rule>
>     <navigation-rule>
>         <navigation-case>
>             <from-outcome>foobar</from-outcome>
>             <to-view-id>/foobar.jsp</to-view-id>
>         </navigation-case>
>     </navigation-rule>
> Assuming you are in the view /foo.jsp and your action method returns "foobar" 
> you would expect to end up matching on the wildcard navigation rule and be 
> sent to /foobar.jsp.
> It looks like the logic on lines 71-72 and 75-79 are erroneous and should be 
> removed as they are present in the getNavigationCase(...) method called on 
> line 73. The net effect of the problem is that even if you find a good match 
> from line 73, if your viewId returns a list from the casesMap the code ends 
> up overwriting the previously determined navigation case with a null - this 
> send you right back to rerendering the view as if you nav case wasn't there 
> at all.
> I took out the lines in question and tested locally and everything seems to 
> work for me...
> -Erik
> Diff:
> Index: 
> core/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
> ===================================================================
> --- 
> core/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
>    (revision 415098)
> +++ 
> core/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
>    (working copy)
> @@ -68,18 +68,8 @@
>              return;
>          }
> -        String viewId = facesContext.getViewRoot().getViewId();
> -        Map casesMap = getNavigationCases(facesContext);
>          NavigationCase navigationCase = getNavigationCase(facesContext, 
> fromAction, outcome);
> -        List casesList = (List)casesMap.get(viewId);
> -        if (casesList != null)
> -        {
> -            // Exact match?
> -            navigationCase = calcMatchingNavigationCase(casesList, 
> fromAction, outcome);
> -        }
> -
> -

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to