Esempio n. 1
0
 /**
  * This method is similar to enclosingPageOfClass. It differs in that it is generic and it
  * inspects the sender argument as well as its parents.
  *
  * @param <T> The class type
  * @param sender the sender component
  * @param c the class
  * @return sender or the first of sender's parents that is assignable from class c
  */
 public static <T> T enclosingComponentOfClass(WOComponent sender, Class<T> c) {
   WOComponent p = sender;
   while (p != null) {
     if (c.isAssignableFrom(p.getClass())) return (T) p;
     p = p.parent();
   }
   return null;
 }
Esempio n. 2
0
 /**
  * Utility to return the first enclosing component that matches the given class, if there is one.
  */
 public static WOComponent enclosingPageOfClass(WOComponent sender, Class c) {
   WOComponent p = sender.parent();
   while (p != null) {
     if (c.isAssignableFrom(p.getClass())) return p;
     p = p.parent();
   }
   return null;
 }