public Component newInstance(Class<? extends Component> cls) { final Object curInfo = ComponentsCtrl.getCurrentInfo(); boolean bSet = true; if (curInfo instanceof ComponentInfo) { bSet = ((ComponentInfo) curInfo).getComponentDefinition() != this; } else if (curInfo instanceof ShadowInfo) { bSet = ((ShadowInfo) curInfo).getComponentDefinition() != this; } if (bSet) ComponentsCtrl.setCurrentInfo(this); final Component comp; try { comp = cls.newInstance(); } catch (Exception ex) { throw UiException.Aide.wrap(ex); } finally { if (bSet) ComponentsCtrl.setCurrentInfo((ComponentDefinition) null); } return comp; }
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]; } }
ComponentDefinition compdef = compInfo.getComponentDefinition();
_def = compInfo.getComponentDefinition(); addSharedAnnotationMap(_def.getAnnotationMap()); addSharedAnnotationMap(compInfo.getAnnotationMap());