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 2010/10/20 00:18:49 UTC

svn commit: r1024431 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/UIComponent.java api/src/main/java/javax/faces/component/UIData.java impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java

Author: lu4242
Date: Tue Oct 19 22:18:48 2010
New Revision: 1024431

URL: http://svn.apache.org/viewvc?rev=1024431&view=rev
Log:
MYFACES-2948 invokeOnComponent does not call pushComponentToEL / popComponentFromEL like visitTree does

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponent.java
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.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=1024431&r1=1024430&r2=1024431&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 Oct 19 22:18:48 2010
@@ -194,22 +194,30 @@ public abstract class UIComponent implem
             throw new NullPointerException();
         }
 
-        // searching for this component?
-        boolean found = clientId.equals(this.getClientId(context));
-        if (found) {
-            try {
-                callback.invokeContextCallback(context, this);
-            } catch (Exception e) {
-                throw new FacesException(e);
+        pushComponentToEL(context, this);
+        try
+        {
+            // searching for this component?
+            boolean found = clientId.equals(this.getClientId(context));
+            if (found) {
+                try {
+                    callback.invokeContextCallback(context, this);
+                } catch (Exception e) {
+                    throw new FacesException(e);
+                }
+                return found;
+            }
+            // Searching for this component's children/facets
+            for (Iterator<UIComponent> it = this.getFacetsAndChildren(); !found && it.hasNext();) {
+                found = it.next().invokeOnComponent(context, clientId, callback);
             }
             return found;
         }
-        // Searching for this component's children/facets
-        for (Iterator<UIComponent> it = this.getFacetsAndChildren(); !found && it.hasNext();) {
-            found = it.next().invokeOnComponent(context, clientId, callback);
+        finally
+        {
+            //all components must call popComponentFromEl after visiting is finished
+            popComponentFromEL(context);
         }
-
-        return found;
     }
 
     /**

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java?rev=1024431&r1=1024430&r2=1024431&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java Tue Oct 19 22:18:48 2010
@@ -313,6 +313,7 @@ public class UIData extends UIComponentB
             setCachedFacesContext(context);
         }
         
+        pushComponentToEL(context, this);
         try
         {
             if (returnValue)
@@ -416,6 +417,8 @@ public class UIData extends UIComponentB
         }
         finally
         {
+            //all components must call popComponentFromEl after visiting is finished
+            popComponentFromEL(context);
             if (!isCachedFacesContext)
             {
                 setCachedFacesContext(null);

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java?rev=1024431&r1=1024430&r2=1024431&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java Tue Oct 19 22:18:48 2010
@@ -658,71 +658,81 @@ public class UIRepeat extends UIComponen
     public boolean invokeOnComponent(FacesContext faces, String clientId,
             ContextCallback callback) throws FacesException
     {
+        
         // get the index-less clientId
-        String indexLessId = getClientId(faces);
-        if (clientId.startsWith(indexLessId))
+        pushComponentToEL(faces, this);
+        try
         {
-            // the index for which the component should be invoked
-            int invokeIndex = -1;
-            
-            // try to get the invokeIndex out of the given clientId.
-            // Note that the clientId of UIRepeat contains the current index,
-            // if the index is >= 0 (see getContainerClientId()).
-            int idxStart = clientId.indexOf(UINamingContainer.getSeparatorChar(faces),
-                    indexLessId.length());
-            if (idxStart != -1 && Character.isDigit(clientId.charAt(idxStart + 1)))
+            String indexLessId = getClientId(faces);
+            if (clientId.startsWith(indexLessId))
             {
-                int idxEnd = clientId.indexOf(UINamingContainer.getSeparatorChar(faces), idxStart + 1);
-                if (idxEnd != -1)
-                {
-                    invokeIndex = Integer.parseInt(clientId.substring(idxStart + 1, idxEnd));
-                }
-            }
-            
-            // safe the current index, count aside
-            final int prevIndex = _index;
-            final int prevCount = _count;
-            
-            try
-            {
-                // save the current scope values and set the right index
-                _captureScopeValues();
-                if (invokeIndex != -1)
-                {
-                    // calculate count for RepeatStatus
-                    _count = _calculateCountForIndex(invokeIndex);
-                }
-                _setIndex(invokeIndex);
+                // the index for which the component should be invoked
+                int invokeIndex = -1;
                 
-                if (_isIndexAvailable())
+                // try to get the invokeIndex out of the given clientId.
+                // Note that the clientId of UIRepeat contains the current index,
+                // if the index is >= 0 (see getContainerClientId()).
+                int idxStart = clientId.indexOf(UINamingContainer.getSeparatorChar(faces),
+                        indexLessId.length());
+                if (idxStart != -1 && Character.isDigit(clientId.charAt(idxStart + 1)))
                 {
-                    return super.invokeOnComponent(faces, clientId, callback);
+                    int idxEnd = clientId.indexOf(UINamingContainer.getSeparatorChar(faces), idxStart + 1);
+                    if (idxEnd != -1)
+                    {
+                        invokeIndex = Integer.parseInt(clientId.substring(idxStart + 1, idxEnd));
+                    }
                 }
-                else if (clientId.equals(indexLessId))
+                
+                // safe the current index, count aside
+                final int prevIndex = _index;
+                final int prevCount = _count;
+                
+                try
                 {
-                    // the only proper case for invokeIndex == -1 (Note that for 
-                    // a invokeIndex of -1 we must not invoke our children or facets)
-                    callback.invokeContextCallback(faces, this);
-                    return true;
+                    // save the current scope values and set the right index
+                    _captureScopeValues();
+                    if (invokeIndex != -1)
+                    {
+                        // calculate count for RepeatStatus
+                        _count = _calculateCountForIndex(invokeIndex);
+                    }
+                    _setIndex(invokeIndex);
+                    
+                    if (_isIndexAvailable())
+                    {
+                        return super.invokeOnComponent(faces, clientId, callback);
+                    }
+                    else if (clientId.equals(indexLessId))
+                    {
+                        // the only proper case for invokeIndex == -1 (Note that for 
+                        // a invokeIndex of -1 we must not invoke our children or facets)
+                        callback.invokeContextCallback(faces, this);
+                        return true;
+                    }
+                    else
+                    {
+                        // most likely no valid clientId
+                        return false;
+                    }
                 }
-                else
+                finally
                 {
-                    // most likely no valid clientId
-                    return false;
+                    // restore the previous count, index and scope values
+                    _count = prevCount;
+                    _setIndex(prevIndex);
+                    _restoreScopeValues();
                 }
             }
-            finally
+            else
             {
-                // restore the previous count, index and scope values
-                _count = prevCount;
-                _setIndex(prevIndex);
-                _restoreScopeValues();
+                // the clientId does not match to this component or one of its children
+                return false;
             }
         }
-        else
+        finally
         {
-            // the clientId does not match to this component or one of its children
-            return false;
+            //all components must call popComponentFromEl after visiting is finished
+            popComponentFromEL(faces);
         }
     }