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:44 UTC

svn commit: r1153001 - /myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java

Author: lu4242
Date: Tue Aug  2 02:28:44 2011
New Revision: 1153001

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

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java?rev=1153001&r1=1153000&r2=1153001&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java Tue Aug  2 02:28:44 2011
@@ -946,17 +946,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())
             {
@@ -993,7 +1015,18 @@ public abstract class UIComponent implem
             UIComponent oldCurrent = null;
             if (componentStack != null && !componentStack.isEmpty())
             {
-                oldCurrent = componentStack.removeFirst();
+                int componentIndex = componentStack.indexOf(this);
+                if (componentIndex >= 0)
+                {
+                    for (int i = 0; i < (componentIndex+1); i++)
+                    {
+                        oldCurrent = componentStack.removeFirst();
+                    }
+                }
+                else
+                {
+                    return;
+                }
             }
             
             if (oldCurrent != null && oldCurrent._isCompositeComponent())