You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/08/05 13:30:12 UTC

svn commit: r982547 - /myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java

Author: lofwyr
Date: Thu Aug  5 11:30:12 2010
New Revision: 982547

URL: http://svn.apache.org/viewvc?rev=982547&view=rev
Log:
added util method to search insite the component tree

Modified:
    myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java?rev=982547&r1=982546&r2=982547&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java Thu Aug  5 11:30:12 2010
@@ -261,6 +261,20 @@ public class ComponentUtil {
     }
   }
 
+  public static <T extends UIComponent> T findDescendant(UIComponent component, Class<T> type) {
+
+    for (UIComponent child : (List<UIComponent>)component.getChildren()) {
+      if (child.getClass().equals(type)) {
+        return (T) component;
+      }
+      final T descendant = findDescendant(child, type);
+      if (descendant != null) {
+        return descendant;
+      }
+    }
+    return null;
+  }
+
   /**
    * Looks for the attribute "for" in the component. If there is any
    * search for the component which is referenced by the "for" attribute,