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 2011/08/02 04:28:06 UTC

svn commit: r1153000 - /myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponent.java

Author: lu4242
Date: Tue Aug  2 02:28:06 2011
New Revision: 1153000

URL: http://svn.apache.org/viewvc?rev=1153000&view=rev
Log:
MYFACES-3254 UIComponent.popComponentFromEL should only pop when the right component is passed

Modified:
    myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponent.java

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponent.java?rev=1153000&r1=1152999&r2=1153000&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponent.java Tue Aug  2 02:28:06 2011
@@ -870,17 +870,39 @@ public abstract class UIComponent implem
         // UIComponent, if any, becomes the current component.
         LinkedList<UIComponent> componentStack = (LinkedList<UIComponent>) contextAttributes.get(UIComponent._COMPONENT_STACK);
         
+        UIComponent oldCurrent = (UIComponent)contextAttributes.get(UIComponent.CURRENT_COMPONENT);
+
         UIComponent newCurrent = null;
         if (componentStack != null && !componentStack.isEmpty())
         {
-            newCurrent = componentStack.removeFirst();
+            if (!this.equals(oldCurrent))
+            {
+                //Check on the componentStack if it can be found
+                int componentIndex = componentStack.indexOf(this);
+                if (componentIndex >= 0)
+                {
+                    for (int i = 0; i < (componentIndex+1); i++)
+                    {
+                        newCurrent = componentStack.removeFirst();
+                    }
+                }
+                else
+                {
+                    //Component not found on the stack. Do not pop.
+                    return;
+                }
+            }
+            else
+            {
+                newCurrent = componentStack.removeFirst();
+            }
         }
         else
         {
             //Reset the current composite component
             contextAttributes.put(UIComponent.CURRENT_COMPOSITE_COMPONENT, null);
         }
-        UIComponent oldCurrent = (UIComponent)contextAttributes.put(UIComponent.CURRENT_COMPONENT, newCurrent);
+        oldCurrent = (UIComponent)contextAttributes.put(UIComponent.CURRENT_COMPONENT, newCurrent);
         
         if (oldCurrent != null && oldCurrent._isCompositeComponent())
         {