incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r418387 - in /incubator/adffaces/trunk/adf-faces/adf-faces-api/src: main/java/org/apache/myfaces/adf/component/ChildArrayList.java test/java/org/apache/myfaces/adf/component/AddRemoveTest.java
Date Fri, 30 Jun 2006 21:49:33 GMT
Author: awiner
Date: Fri Jun 30 14:49:33 2006
New Revision: 418387

URL: http://svn.apache.org/viewvc?rev=418387&view=rev
Log:
ADFFACES-41:  Children out of order in ChildArrayList when re-added to different parent. 
Thanks to John Fan for the patch.

Modified:
    incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/ChildArrayList.java
    incubator/adffaces/trunk/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/AddRemoveTest.java

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/ChildArrayList.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/ChildArrayList.java?rev=418387&r1=418386&r2=418387&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/ChildArrayList.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/ChildArrayList.java
Fri Jun 30 14:49:33 2006
@@ -45,9 +45,16 @@
       throw new IndexOutOfBoundsException("index:"+index+" size:"+size());
 
     UIComponent child = (UIComponent) element;
-    if (child.getParent() != null)
+
+    UIComponent oldParent = child.getParent();
+    if (oldParent != null)
     {
-      index = __removeFromParent(child, index);
+      int adjustedIndex = __removeFromParent(child, index);
+      // Only adjust the index when the child is re-added to the same parent
+      if (oldParent == _parent)
+      {
+        index = adjustedIndex; 
+      }
     }
 
     child.setParent(_parent);

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/AddRemoveTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/AddRemoveTest.java?rev=418387&r1=418386&r2=418387&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/AddRemoveTest.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-api/src/test/java/org/apache/myfaces/adf/component/AddRemoveTest.java
Fri Jun 30 14:49:33 2006
@@ -73,6 +73,10 @@
     assertEquals(0, a.getChildren().size());
     assertEquals(2, e.getChildren().size());
     assertEquals(e, c.getParent());
+
+    //Make sure the children are in the right order under "e" 
+    assertEquals(e.getChildren().get(0), d);
+    assertEquals(e.getChildren().get(1), c);
   }
 
   public void testAddFacet()



Mime
View raw message