/* package */ static boolean isTemplate(Component comp) { //bug #1941947 Cannot find associated CollectionItem error return comp != null && comp.getAttribute(OWNER) != null; }
public Form getForm(Component comp, String id) { String oldid = (String) comp.getAttribute(FORM_ID, Component.COMPONENT_SCOPE); if (oldid == null || !oldid.equals(id)) { //return null if the id is not correct return null; } return (Form) comp.getAttribute(id); }
protected int getRenderedIndex(Component owner, int childIndex) { Map<String, Integer> indexes = (Map<String, Integer>) owner.getAttribute(RENDERED_COMPONENTS); if (indexes != null) { Integer result = indexes.get(String.valueOf(childIndex)); if (result == null) return childIndex; return result; } return childIndex; }
/*package*/ static boolean isDistinct(Component comp) { Map args = (Map) comp.getAttribute(DataBinder.ARGS); boolean distinct = true; if (args != null) { final String distinctstr = (String) args.get("distinct"); if (distinctstr != null) { distinct = Boolean.valueOf(distinctstr).booleanValue(); } } return distinct; }
/** Whether this component and attribute associated with a binding. */ public boolean existBinding(Component comp, String attr) { if (isClone(comp)) { comp = (Component) comp.getAttribute(TEMPLATE); } if (_compBindingMap.containsKey(comp)) { Map<String, Binding> attrMap = _compBindingMap.get(comp); return attrMap.containsKey(attr); } return false; }
private Component lookupAossicatedFormComponent(String formId, Component associatedComp) { String fid = null; Component p = associatedComp; while (p != null) { fid = (String) p.getAttribute(FORM_ID); //check in default component scope if (fid != null && fid.equals(formId)) { break; } p = p.getParent(); } return p; }
/** Given component and attr, return the associated {@link Binding}. * @param comp the concerned component * @param attr the concerned attribute */ public Binding getBinding(Component comp, String attr) { if (isClone(comp)) { comp = (Component) comp.getAttribute(TEMPLATE); } Map<String, Binding> attrMap = _compBindingMap.get(comp); return attrMap != null ? attrMap.get(attr) : null; }
/** Given component, return the associated list of {@link Binding}s. * @param comp the concerned component */ public Collection<Binding> getBindings(Component comp) { if (isClone(comp)) { comp = (Component) comp.getAttribute(TEMPLATE); } Map<String, Binding> attrMap = _compBindingMap.get(comp); return attrMap != null ? attrMap.values() : null; }
protected void recordRenderedIndex(Component owner, int itemSize) { List<Component[]> indexList = (List<Component[]>) owner .getAttribute(BinderCtrl.CHILDREN_BINDING_RENDERED_COMPONENTS); if (indexList == null) { super.recordRenderedIndex(owner, itemSize); } }
private void addChildrenBindingRenderedComps(final Component owner, Component[] items, int index) { List<Component[]> cbrCompsList = (List<Component[]>) owner .getAttribute(BinderCtrl.CHILDREN_BINDING_RENDERED_COMPONENTS); if (cbrCompsList == null) cbrCompsList = new LinkedList<Component[]>(); cbrCompsList.add(index, items); owner.setAttribute(BinderCtrl.CHILDREN_BINDING_RENDERED_COMPONENTS, cbrCompsList); }
@SuppressWarnings("unchecked") private static Set<String> getEvtLisSet(Component comp, String name) { Object obj = comp.getAttribute(name); if (obj != null) return (Set<String>) obj; Set<String> set = new HashSet<String>(); comp.setAttribute(name, set); return set; }
/** Note: data must be non-null. */ @SuppressWarnings("unchecked") private static Integer getKeyOfData(Component comp, Object data) { Object[] inf = (Object[]) comp.getAttribute(Attributes.ECHO_DATA); if (inf == null) comp.setAttribute(Attributes.ECHO_DATA, inf = new Object[] { new Integer(0), new HashMap(4) }); final Integer key = (Integer) inf[0]; ((Map) inf[1]).put(key, data); inf[0] = new Integer(key.intValue() + 1); return key; }
/** Whether this component associated with any bindings. */ public boolean existsBindings(Component comp) { if (isClone(comp)) { comp = (Component) comp.getAttribute(TEMPLATE); } return _compBindingMap.containsKey(comp); }
/** Tests if the given attribute is defined in a component or in library property. * @param name the name of the attribute * @param defValue the default value if neither component's attribute or library property is defined * for the given name * @param recurse whether to look up the ancestor's attribute * @since 5.0.7 */ public static final boolean testAttribute(Component comp, String name, boolean defValue, boolean recurse) { Object val = comp.getAttribute(name, recurse); if (val == null) val = Library.getProperty(name); return val instanceof Boolean ? ((Boolean) val).booleanValue() : val != null ? "true".equals(val) : defValue; }
/*package*/ static Component lookupClone(Component srcClone, Component srcTemplate) { if (isTemplate(srcTemplate) && srcClone != null) { Map templatemap = (Map) srcClone.getAttribute(TEMPLATEMAP); return myLookupClone(srcTemplate, templatemap); } return null; }
/*package*/ Component getCollectionOwner(Component comp) { if (isTemplate(comp)) { return (Component) comp.getAttribute(OWNER); } return getComponentCollectionOwner(comp); }
public boolean hasAnnotatedMethod(Binder binder) { Component rootComp = binder.getView(); Object viewModel = rootComp.getAttribute(VM); final Class<?> vmClz = BindUtils.getViewModelClass(viewModel); List<Method> methods = getAnnotateMethods(annoClass, vmClz); return (!methods.isEmpty()); }
private void removeForm(Component comp) { String id = (String) comp.getAttribute(FORM_ID, Component.COMPONENT_SCOPE); if (id != null) { comp.removeAttribute(FORM_ID); Object form = comp.removeAttribute(id); if (form != null) initSaveFormMap().remove(form); comp.removeAttribute(id + "Status"); } }
public String getViewModelName() { if (getBinder() == null) return null; String vmName = (String) _binder.getView().getAttribute(BindComposer.VM_ID); if (vmName == null && _binder.getView().hasAttribute(VM)) return VM; return vmName; }
private void mySetupTemplateComponent(Component comp, Object owner, Component item) { if (existsBindings(comp)) { if (comp.getAttribute(OWNER) != null) { comp.setAttribute(HASTEMPLATEOWNER, Boolean.TRUE); //owner is a template } comp.setAttribute(OWNER, owner); comp.setAttribute(ITEM, item); } for (Component c : comp.getChildren()) { mySetupTemplateComponent(c, owner, item); //recursive } }