/*package*/ static boolean matchType(Component component, String type) { if (type == null) return true; return component.getDefinition().getName().toLowerCase(java.util.Locale.ENGLISH) .equals(type.toLowerCase(java.util.Locale.ENGLISH)); }
public String getType() { return comp.getDefinition().getName(); }
/*package*/ static boolean matchType(Component component, String type){ if(type == null) return true; return component.getDefinition().getName().toLowerCase().equals(type.toLowerCase()); }
public void addComponent(Component comp) { //to avoid misuse, check whether new comp belongs to the same device type final LanguageDefinition langdef = comp.getDefinition().getLanguageDefinition(); if (langdef != null && !_devType.equals(langdef.getDeviceType())) throw new UiException( "Component, " + comp + ", does not belong to the same device type of the desktop, " + _devType); final String uuid = comp.getUuid(); final Component old = _comps.put(uuid, comp); if (old != comp && old != null) { _comps.put(uuid, old); //recover throw new InternalError("Caller shall prevent it: Register a component twice: " + comp); } /* For performance reason, we don't check if a component is detached and attached back (in another execution). Rather, reset _uuid when it is recycled (refer to AbstractComponent.setPage0 (the caller of removeComponent has to reset) else if (_uuidRecycle != null && !_uuidRecycle.isEmpty()) { for (RecycleInfo ri: _uuidRecycle) { final List<String> uuids = ri.uuids; if (uuids.remove(uuid)) { if (uuids.isEmpty()) it.remove(); break; } } }*/ }
"self".equals(attnm) ? null: attnm, true); else if(target.getDefinition().isMacro()) ((DynamicPropertied)target).setDynamicProperty(attnm, value); else Fields.setByCompound(target, attnm, value, true); else if(target.getDefinition().isMacro()) ((DynamicPropertied)target).setDynamicProperty(attnm, value); else Fields.setByCompound(target, attnm, value, true);
private static Component[] execCreateChild(CreateInfo ci, Component parent, ComponentInfo childInfo, ReplaceableText replaceableText, Component insertBefore) { final ComponentDefinition childdef = childInfo.getComponentDefinition(); if (childdef.isInlineMacro()) { if (insertBefore != null) throw new UnsupportedOperationException("The inline macro doesn't support template"); final Map<String, Object> props = new HashMap<String, Object>(); props.put("includer", parent); childInfo.evalProperties(props, ci.page, parent, true); return new Component[] { ci.exec.createComponents(childdef.getMacroURI(), parent, props) }; } else { String rt = null; if (replaceableText != null) { // ZK-3549 should ignore blank but was not able to do so in Parser, e.g. applying template if (parent == null || parent.getDefinition().isBlankPreserved()) { rt = replaceableText.text; } replaceableText.text = childInfo.getReplaceableText(); if (replaceableText.text != null) return new Component[0]; //Note: replaceableText is one-shot only //So, replaceable text might not be generated //and it is ok since it is only blank string } Component child = execCreateChild0(ci, parent, childInfo, rt, insertBefore); return child != null ? new Component[] { child } : new Component[0]; } }
/** * Creates and registers the component. * Called by {@link #doTag}. */ /*package*/ void initComponent() throws Exception { if(_roottag==null) throw new IllegalStateException("Must be nested inside the page tag: "+this); String tagName = getComponentName(); Page page = this._roottag.getPage(); ComponentDefinition compdef = page.getComponentDefinition(tagName, true); if(compdef==null) throw new JspException("can't find this Component's definition:"+tagName); _comp = (Component) compdef.resolveImplementationClass(page, getUse()).newInstance(); _composeHandle.doBeforeComposeChildren(_comp); if (_parenttag != null)_parenttag.addChildTag(this); else _roottag.addChildTag(this); _comp.getDefinition().applyProperties(_comp); // apply attributes to component... evaluateDynaAttributes(_comp, _attrMap); } /**
_comp.getDefinition().applyProperties(_comp);
protected void addItemReference(Component modelOwner, final Component comp, int index, String varnm) { // ZK-2456: if comp is native, add reference to all of its children if (comp.getDefinition().isNative()) { for (Component child : comp.getChildren()) { addItemReference(modelOwner, child, index, varnm); } } else { final Binder binder = BinderUtil.getBinder(comp, true); if (binder == null) return; //no binder // ZK-2552: use an expression instead of solid number to represent index final String expression; if (comp.hasAttribute(IS_TEMPLATE_MODEL_ENABLED_ATTR)) { expression = CURRENT_INDEX_RESOLVER_ATTR; } else { expression = BindELContext.getModelName(modelOwner) + "[" + index + "]"; } //should not use binder.addReferenceBinding(comp, varnm, expression, null); here, it will mark comp bound. //it is safe that we set to comp attr here since the component is created by renderer/binder. comp.setAttribute(varnm, new ReferenceBindingImpl(binder, comp, varnm, expression)); //reference } } }
public JSONObject toJSON() { JSONObject json = new JSONObject(); putEssential(json, "type", _type); if (_comp != null) { put(json, "widget", _comp.getDefinition().getName()); put(json, "uuid", _comp.getUuid()); put(json, "id", _comp.getId()); } put(json, "subtype", _subtype); put(json, "note", toString(_note, 300)); put(json, "location", _location); return json; }