/** Applies the variable element against the parent component. * * @param comp the parent component (it cannot be null) */ public void apply(Component comp) { if (_vars != null && isEffective(comp)) { final Evaluator eval = getEvaluator(); for (Map.Entry<String, Object> me : _vars.entrySet()) { final String name = me.getKey(); final Object value = me.getValue(); comp.getSpaceOwner().setAttribute(name, Utils.evaluateComposite(eval, comp, value), !_local); } } }
public Component getFellow(String compId) throws ComponentNotFoundException { if (this instanceof IdSpace) { final Component comp = _auxinf.spaceInfo.fellows.get(compId); if (comp == null) throw new ComponentNotFoundException("Fellow component not found: " + compId); return comp; } final IdSpace idspace = getSpaceOwner(); if (idspace == null) throw new ComponentNotFoundException("This component doesn't belong to any ID space: " + this); return idspace.getFellow(compId); }
public Component getFellowIfAny(String compId) { if (this instanceof IdSpace) return _auxinf.spaceInfo.fellows.get(compId); final IdSpace idspace = getSpaceOwner(); return idspace == null ? null : idspace.getFellowIfAny(compId); }
public boolean hasFellow(String compId) { if (this instanceof IdSpace) return _auxinf.spaceInfo.fellows.containsKey(compId); final IdSpace idspace = getSpaceOwner(); return idspace != null && idspace.hasFellow(compId); }
public Collection<Component> getFellows() { if (this instanceof IdSpace) return Collections.unmodifiableCollection(_auxinf.spaceInfo.fellows.values()); final IdSpace idspace = getSpaceOwner(); if (idspace != null) return idspace.getFellows(); return Collections.emptyList(); }
final IdSpace idspace = getSpaceOwner(); if (idspace != null) return idspace.getAttributes(); return Collections.emptyMap(); case PAGE_SCOPE:
/** Checks the uniqueness in ID space when changing ID. */ private static void checkIdSpaces(final AbstractComponent comp, String newId) { if (comp instanceof NonFellow) return; //no need to check if (comp instanceof IdSpace && comp._auxinf.spaceInfo.fellows.containsKey(newId)) throw new UiException("Not unique in the ID space of " + comp); final IdSpace is = getSpaceOwnerOfParent(comp); if (is instanceof Component) { if (((AbstractComponent) is)._auxinf.spaceInfo.fellows.containsKey(newId)) throw new UiException("Not unique in ID space " + is + ": " + newId); } else if (is != null) { if (is.hasFellow(newId)) throw new UiException("Not unique in ID space " + is + ": " + newId); } }
/** Injects the fellows in the context of the given IdSpace. */ public void wireFellows(final IdSpace idspace) { //inject fellows final Collection<Component> fellows = idspace.getFellows(); for (Component xcomp : fellows) injectFellow(xcomp); //inject space owner ancestors if (idspace instanceof Component) { for (IdSpace is = idspace;;) { final Component parent = is instanceof Component ? ((Component) is).getParent() : null; if (parent == null) { //hit page final Page page = ((Component) idspace).getPage(); if (page != null) injectFellow(page); break; } is = parent.getSpaceOwner(); injectFellow(is); } } else { injectFellow((Page) idspace); } }
setBean(beanid, val); } else if (!setZScriptVariable(comp, beanid, val)) { comp.getSpaceOwner().setAttribute(beanid, val, true);
public Component getFellowIfAny(String compId, boolean recurse) { if (!recurse) return getFellowIfAny(compId); for (IdSpace idspace = getSpaceOwner(); idspace != null;) { Component f = idspace.getFellowIfAny(compId); if (f != null) return f; idspace = Components.getParentIdSpace(idspace); } return null; }
private static void checkIdSpacesDown(Component comp, IdSpace owner) { final String compId = comp.getId(); if (!(comp instanceof NonFellow) && !isAutoId(compId) && (owner instanceof Component ? ((AbstractComponent) owner)._auxinf.spaceInfo.fellows.containsKey(compId) : owner.hasFellow(compId))) throw new UiException("Not unique in the ID space of " + owner + ": " + compId); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) checkIdSpacesDown(ac, owner); //recursive }
} else if (space.getFellowIfAny(id) == comp) { if (sb.length() > 0) sb.append('/');
public boolean hasAttributeOrFellow(String name, boolean recurse) { if (hasAttribute(name) || (this instanceof IdSpace && hasFellow(name))) return true; if (recurse) { if (_parent != null) return _parent.hasAttributeOrFellow(name, true); if (_page != null) return _page.hasAttributeOrFellow(name, true); if (this instanceof ShadowElement) { Component shadowHost = ((ShadowElement) this).getShadowHost(); if (shadowHost != null) return shadowHost.hasAttributeOrFellow(name, true); } if (!(this instanceof IdSpace)) return getVirtualIdSpace().hasFellow(name); } return false; }
return null; final Component c = is.getFellowIfAny(nm); if (k < 0 || c == null) return c;
public Object getAttributeOrFellow(String name, boolean recurse) { Object val = getAttribute(name); if (val != null || hasAttribute(name)) return val; if (this instanceof IdSpace) { //fellow last val = getFellowIfAny(name); if (val != null) return val; } if (recurse) { if (_parent != null) return _parent.getAttributeOrFellow(name, true); if (_page != null) return _page.getAttributeOrFellow(name, true); if (this instanceof ShadowElement) { Component shadowHost = ((ShadowElement) this).getShadowHost(); if (shadowHost != null) return shadowHost.getAttributeOrFellow(name, true); } if (!(this instanceof IdSpace)) return getVirtualIdSpace().getFellowIfAny(name); } return null; }