You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2013/08/30 04:19:13 UTC

svn commit: r1518881 - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/application/NavigationHandlerImpl.java test/resources/org/apache/myfaces/application/flow/WEB-INF/flow1-flow.xml

Author: lu4242
Date: Fri Aug 30 02:19:13 2013
New Revision: 1518881

URL: http://svn.apache.org/r1518881
Log:
MYFACES-3764 Implement FlowHandler.getLastDisplayedViewId(FacesContext context) logic

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/flow/WEB-INF/flow1-flow.xml

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java?rev=1518881&r1=1518880&r2=1518881&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java Fri Aug 30 02:19:13 2013
@@ -216,6 +216,7 @@ public class NavigationHandlerImpl
                 ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
                 //create new view
                 String newViewId = navigationCase.getToViewId(facesContext);
+                String lastDisplayedViewId = null;
                 // JSF 2.0 the javadoc of handleNavigation() says something like this 
                 // "...If the view has changed after an application action, call
                 // PartialViewContext.setRenderAll(true)...". The effect is that ajax requests
@@ -232,6 +233,8 @@ public class NavigationHandlerImpl
 
                 if (facesContext.getViewRoot() != null)
                 {
+                    lastDisplayedViewId = facesContext.getViewRoot().getViewId();
+                    
                     if (facesContext.getViewRoot().getAttributes().containsKey("oam.CALL_PRE_DISPOSE_VIEW"))
                     {
                         facesContext.getAttributes().put(SKIP_ITERATION_HINT, Boolean.TRUE);
@@ -256,7 +259,7 @@ public class NavigationHandlerImpl
                             Flow targetFlow = navigationContext.getTargetFlows().get(i);
                             flowHandler.transition(facesContext, sourceFlow, targetFlow, 
                                 navigationContext.getFlowCallNodes().get(i), 
-                                navigationContext.getNavigationCase().getToViewId(facesContext));
+                                lastDisplayedViewId);
                             sourceFlow = targetFlow;
                         }
                     }
@@ -598,7 +601,10 @@ public class NavigationHandlerImpl
                                 {
                                     navigationContext.setSourceFlow(
                                         navigationContext.getCurrentFlow(facesContext));
-                                }                                    
+                                }
+                                String lastDisplayedViewId = navigationContext.getLastDisplayedViewId(facesContext, 
+                                            currentFlow);
+                                
                                 // This is the part when the pseudo "recursive call" is done. 
                                 navigationContext.popFlow(facesContext);
                                 currentFlow = navigationContext.getCurrentFlow(facesContext);
@@ -618,16 +624,11 @@ public class NavigationHandlerImpl
                                 else
                                 {
                                     // No navigation case
-                                    if (currentFlow != null)
+                                    if (lastDisplayedViewId != null)
                                     {
-                                        String lastDisplayedViewId = navigationContext.getLastDisplayedViewId(facesContext, 
-                                            currentFlow);
-                                        if (lastDisplayedViewId != null)
-                                        {
-                                            navigationCase = createNavigationCase(
-                                                viewId, flowNode.getId(), lastDisplayedViewId);
-                                            complete = true;
-                                        }
+                                        navigationCase = createNavigationCase(
+                                            viewId, flowNode.getId(), lastDisplayedViewId);
+                                        complete = true;
                                     }
                                 }
                                 if (currentFlow == null)

Modified: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/flow/WEB-INF/flow1-flow.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/flow/WEB-INF/flow1-flow.xml?rev=1518881&r1=1518880&r2=1518881&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/flow/WEB-INF/flow1-flow.xml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/application/flow/WEB-INF/flow1-flow.xml Fri Aug 30 02:19:13 2013
@@ -30,7 +30,11 @@
             <from-outcome>exit</from-outcome>
         </flow-return>
         
-        <flow-return id="back"/>
+        <flow-return id="back">
+            <!-- note the outcome will not be resolved, so the
+            last displayed view should be used -->
+            <from-outcome>back</from-outcome>
+        </flow-return>
         
         <navigation-rule>
             <from-view-id>*</from-view-id>
@@ -75,9 +79,7 @@
              so the navigation algorithm should not return any navigation
              case and it should be used the last displayed view id by
              default-->
-        <flow-return id="back">
-            <from-outcome>back</from-outcome>
-        </flow-return>
+        <flow-return id="back"/>
         
         <navigation-rule>
             <from-view-id>*</from-view-id>