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:37:19 UTC
svn commit: r982548 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
Author: lofwyr
Date: Thu Aug 5 11:37:19 2010
New Revision: 982548
URL: http://svn.apache.org/viewvc?rev=982548&view=rev
Log:
added util method to search insite the component tree
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=982548&r1=982547&r2=982548&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Thu Aug 5 11:37:19 2010
@@ -220,6 +220,20 @@ public class ComponentUtils {
}
}
+ 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,
Modified: myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java?rev=982548&r1=982547&r2=982548&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java Thu Aug 5 11:37:19 2010
@@ -112,6 +112,10 @@ public class ComponentUtil {
return new ArrayList<UIForm>((List) ComponentUtils.findSubForms(component));
}
+ public static <T extends UIComponent> T findDescendant(UIComponent component, Class<T> type) {
+ return ComponentUtils.findDescendant(component, type);
+ }
+
public static String findClientIdFor(UIComponent component, FacesContext facesContext) {
return ComponentUtils.findClientIdFor(component, facesContext);
}