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/06 02:38:54 UTC

svn commit: r1154418 - in /myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component: UIComponentBase.java _ComponentUtils.java

Author: lu4242
Date: Sat Aug  6 00:38:53 2011
New Revision: 1154418

URL: http://svn.apache.org/viewvc?rev=1154418&view=rev
Log:
MYFACES-3268 UIComponentBase.findComponent does not allow use the same id for a child component.

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

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponentBase.java?rev=1154418&r1=1154417&r2=1154418&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/UIComponentBase.java Sat Aug  6 00:38:53 2011
@@ -616,8 +616,34 @@ public abstract class UIComponentBase ex
             throw new IllegalArgumentException("Intermediate identifier " + id + " in search expression " + expr
                     + " identifies a UIComponent that is not a NamingContainer");
 
-        return findBase.findComponent(expr.substring(separator + 1));
-
+        // At this point, findBase has a NamingContainer that match with the id.
+        // So we need to call findComponent over the rest of the expression without take
+        // into account the base id, to allow use the same id on the inner component.
+        //return findBase.findComponent(expr.substring(separator + 1));
+        String innerExpr = expr.substring(separator + 1);
+        if (findBase.getFacetCount() > 0)
+        {
+            for (UIComponent facet : findBase.getFacets().values())
+            {
+                UIComponent find = facet.findComponent(innerExpr);
+                if (find != null)
+                {
+                    return find;
+                }
+            }
+        }
+        if (findBase.getChildCount() > 0)
+        {
+            for (int i = 0, childCount = findBase.getChildCount(); i < childCount; i++)
+            {
+                UIComponent find = findBase.getChildren().get(i).findComponent(innerExpr);
+                if (find != null)
+                {
+                    return find;
+                }
+            }
+        }
+        return null;
     }
 
     /**

Modified: myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/_ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/_ComponentUtils.java?rev=1154418&r1=1154417&r2=1154418&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/_ComponentUtils.java (original)
+++ myfaces/core/branches/2.0.x/api/src/main/java/javax/faces/component/_ComponentUtils.java Sat Aug  6 00:38:53 2011
@@ -160,6 +160,8 @@ class _ComponentUtils
         if (id.equals(cmp.getId()))
             return true;
 
+        /* By the spec, findComponent algorithm does not take into account UIData.rowIndex() property,
+         * because it just scan over nested plain ids. 
         if (cmp instanceof UIData)
         {
             UIData uiData = ((UIData)cmp);
@@ -170,6 +172,7 @@ class _ComponentUtils
             }
             return id.equals(cmp.getId() + separatorChar + uiData.getRowIndex());
         }
+        */
 
         return false;
     }