/** * 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); } /**
_compDef = page.getComponentDefinition(_tag, true); if(_compDef==null) throw new JspException("can't find this Component's definition:"+_tag);
public void setDefinition(String name) { final Execution exec = Executions.getCurrent(); if (exec != null) { final ExecutionCtrl execCtrl = (ExecutionCtrl) exec; final PageDefinition pgdef = execCtrl.getCurrentPageDefinition(); final Page page = execCtrl.getCurrentPage(); ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(name, true) : page != null ? page.getComponentDefinition(name, true) : null; if (compdef == null) compdef = Impls.getDefinitionByDeviceType(this, exec.getDesktop().getDeviceType(), name); if (compdef != null) { setDefinition(compdef); return; } } else { for (String deviceType : LanguageDefinition.getDeviceTypes()) { final ComponentDefinition compdef = Impls.getDefinitionByDeviceType(this, deviceType, name); if (compdef != null) { setDefinition(compdef); return; } } } throw new ComponentNotFoundException(name + " not found"); }
/** Returns the component definition of the specified class, or null * if not found. */ /*package*/ static ComponentDefinition getDefinition(Execution exec, Class<? extends Component> cls) { if (exec != null) { final ExecutionCtrl execCtrl = (ExecutionCtrl) exec; final PageDefinition pgdef = execCtrl.getCurrentPageDefinition(); final Page page = execCtrl.getCurrentPage(); final ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(cls, true) : page != null ? page.getComponentDefinition(cls, true) : null; if (compdef != null && compdef.getLanguageDefinition() != null) return compdef; //already from langdef (not from pgdef) final ComponentDefinition compdef2 = Components.getDefinitionByDeviceType(exec.getDesktop().getDeviceType(), cls); return compdef != null && (compdef2 == null || !Objects.equals(compdef.getImplementationClass(), compdef2.getImplementationClass())) ? compdef : compdef2; //Feature 2816083: use compdef2 if same class } for (String deviceType : LanguageDefinition.getDeviceTypes()) { final ComponentDefinition compdef = Components.getDefinitionByDeviceType(deviceType, cls); if (compdef != null) return compdef; } return null; }