You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ms...@apache.org on 2013/02/28 22:27:38 UTC

svn commit: r1451361 - /myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java

Author: mstarets
Date: Thu Feb 28 21:27:37 2013
New Revision: 1451361

URL: http://svn.apache.org/r1451361
Log:
TRINIDAD-2369 - Mojarra 2.1.18 partial state saving incompatibility when moving a facet

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java?rev=1451361&r1=1451360&r2=1451361&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ChildArrayList.java Thu Feb 28 21:27:37 2013
@@ -22,6 +22,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import java.util.Map;
+
 import javax.faces.component.UIComponent;
 
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
@@ -195,11 +197,19 @@ class ChildArrayList extends ArrayList<U
       }
     }
     
-    Collection<UIComponent> facets = parent.getFacets().values();
-    if (facets.contains(component))
+    // TRINIDAD-2369: Until TRINIDAD-2368 is fixed, we have to call remove() on the map
+    // returned by getFacets() rather than calling remove() on getFacets().values()
+    // Note that the old code used to call getFacets().values().contains(), which would iterate on the entry set.
+    // The new code performs the same iteration, so it should not be any slower.
+    
+    Map<String, UIComponent> facets = parent.getFacets();
+    for (Map.Entry<String, UIComponent> entry: facets.entrySet())
     {
-      facets.remove(component);
-      return index;
+      if (entry.getValue() == component)
+      {
+        facets.remove(entry.getKey());
+        return index;
+      }
     }
 
     // Not good - the child thought it was in a parent,