/** * 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; }
/** * Utility to return the outermost page that is a D2W page. This is needed because this component * might be embedded inside a plain page. */ public static D2WPage topLevelD2WPage(WOComponent sender) { WOComponent p = sender.parent(); WOComponent last = null; while (p != null) { if (p instanceof D2WPage) { last = p; } p = p.parent(); } return (D2WPage) last; }
/** * 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; }
public WOComponent applyResult(String resultPath) { setValueForBinding(resultPath, "attributeToSet"); WOComponent result = (WOComponent) valueForBinding("saveAction"); if (result == null) { WOComponent temp = parent(); do { result = temp; temp = result.parent(); } while (temp != null); result.ensureAwakeInContext(context()); } return result; }