myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1154419 - in /myfaces/core/trunk/api/src/main/java/javax/faces/component: UIComponentBase.java _ComponentUtils.java
Date Sat, 06 Aug 2011 00:39:07 GMT
Author: lu4242
Date: Sat Aug  6 00:39:06 2011
New Revision: 1154419

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

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

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java?rev=1154419&r1=1154418&r2=1154419&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java Sat Aug
 6 00:39:06 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/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java?rev=1154419&r1=1154418&r2=1154419&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java Sat Aug
 6 00:39:06 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;
     }



Mime
View raw message