You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sl...@apache.org on 2008/11/13 00:32:25 UTC

svn commit: r713564 - /myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java

Author: slessard
Date: Wed Nov 12 15:32:25 2008
New Revision: 713564

URL: http://svn.apache.org/viewvc?rev=713564&view=rev
Log:
MYFACES-1945 - Implement UIComponent.pushComponentToEL

Modified:
    myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java

Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java?rev=713564&r1=713563&r2=713564&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/component/UIComponent.java Wed Nov 12 15:32:25 2008
@@ -19,6 +19,7 @@
 package javax.faces.component;
 
 import java.io.IOException;
+import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -487,9 +488,29 @@
         contextAttributes.put(UIComponent.CURRENT_COMPONENT, componentStack.pop());
     }
 
+    @SuppressWarnings("unchecked")
     protected void pushComponentToEL(FacesContext context, UIComponent component)
     {
-        // TODO: JSF 2.0 #14
+        Map<Object, Object> contextAttributes = context.getAttributes();        
+        UIComponent currentComponent = (UIComponent) contextAttributes.get(UIComponent.CURRENT_COMPONENT);
+        
+        if(currentComponent != null)
+        {
+            Deque<UIComponent> componentStack = (Deque<UIComponent>) contextAttributes.get(UIComponent._COMPONENT_STACK);
+            if(componentStack == null)
+            {
+                componentStack = new ArrayDeque<UIComponent>();
+                contextAttributes.put(UIComponent._COMPONENT_STACK, componentStack);
+            }
+            
+            componentStack.push(currentComponent);
+        }
+        
+        // Push the current UIComponent this to the FacesContext  attribute map using the key CURRENT_COMPONENT 
+        // saving the previous UIComponent associated with CURRENT_COMPONENT for a subsequent call to 
+        // popComponentFromEL(javax.faces.context.FacesContext).
+        contextAttributes.put(UIComponent.CURRENT_COMPONENT, component);
+ 
     }
 
     /**