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 2010/12/03 21:31:28 UTC

svn commit: r1041984 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java

Author: lu4242
Date: Fri Dec  3 20:31:28 2010
New Revision: 1041984

URL: http://svn.apache.org/viewvc?rev=1041984&view=rev
Log:
MYFACES-2985 Viewscoped bean does not get destroyed when navigating with faces-redirect to a non-jsf-page

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/NavigationHandlerImpl.java

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=1041984&r1=1041983&r2=1041984&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 Dec  3 20:31:28 2010
@@ -97,6 +97,18 @@ public class NavigationHandlerImpl
                 String toViewId = navigationCase.getToViewId(facesContext);
                 String redirectPath = viewHandler.getRedirectURL(facesContext, toViewId, navigationCase.getParameters(), navigationCase.isIncludeViewParams());
                 
+                //Clear ViewMap if we are redirecting to other resource
+                UIViewRoot viewRoot = facesContext.getViewRoot(); 
+                if (viewRoot != null && !viewRoot.getViewId().equals(toViewId))
+                {
+                    //call getViewMap(false) to prevent unnecessary map creation
+                    Map<String, Object> viewMap = viewRoot.getViewMap(false);
+                    if (viewMap != null)
+                    {
+                        viewMap.clear();
+                    }
+                }
+                
                 // 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