/** Redraw the specified component into a string. */ private static String redraw(Component comp) throws IOException { final StringWriter out = new StringWriter(1024 * 8); ((ComponentCtrl) comp).redraw(out); return out.toString(); }
final Annotation annot = ((ComponentCtrl) comp).getAnnotation(null, "format"); String pattern = null; if (annot != null) {
public void checkBinding(Binder binder, Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; for (String p : compCtrl.getAnnotatedProperties()) { if (BINDER_ATTR.equals(p) || VIEW_MODEL_ATTR.equals(p) || VALIDATION_MESSAGES_ATTR.equals(p)) { continue; for (Annotation anno : compCtrl.getAnnotations(p)) { String nm = anno.getName(); try {
/*package*/ void moveToNextShadowSibling(Component next) { _comp = next; _compChildIndex++; // ZK-2944: status clearing is conditional, let the caller handle it // reset the status when moving to siblings _isShadowHost = !((ComponentCtrl) next).getShadowRoots().isEmpty(); }
/** * Renders the children directly to the given output. Notice it is called only if * {@link #redraw} is going to render the content (HTML tags) directly. If it is about to * generate the JavaScript code {@link #redrawChildren} will be called instead. * <p> * You have to override this method if the deriving class has additional information to render. * * @since 5.0.7 */ protected void redrawChildrenDirectly(TagRenderContext rc, Execution exec, java.io.Writer out) throws java.io.IOException { for (Component child = getFirstChild(); child != null;) { Component next = child.getNextSibling(); if (((ComponentCtrl) child).getExtraCtrl() instanceof DirectContent) { ((ComponentCtrl) child).redraw(out); } else { HtmlPageRenders.setDirectContent(exec, false); rc.renderBegin(child, null, getSpecialRendererOutput(child), true); HtmlPageRenders.outStandalone(exec, child, out); rc.renderEnd(child); HtmlPageRenders.setDirectContent(exec, true); } child = next; } }
/** * @deprecated since 6.5.4 */ @SuppressWarnings("rawtypes") public static Annotation getOverrideAnnotation(ComponentCtrl compCtrl, String propName, String annoName) { Collection<Annotation> annos = compCtrl.getAnnotations(propName, annoName); if (annos.size() <= 0) return null; //TODO the real implementation, currently I use the last one if (annos instanceof List) { return (Annotation) ((List) annos).get(((List) annos).size() - 1); } Iterator<Annotation> it = annos.iterator(); Annotation anno = it.next(); while (it.hasNext()) { anno = it.next(); } return anno; }
_previousInsertion = insertBefore.getPreviousSibling(); } else { List<ShadowElement> shadowRoots = ((ComponentCtrl) host).getShadowRoots(); ShadowElement lastShadowElement = shadowRoots.isEmpty() ? null : shadowRoots.get(shadowRoots.size() - 1); Component prev = (Component) lastShadowElement; ((ComponentCtrl) host).addShadowRoot(this); final Desktop desktop = host.getDesktop(); if (desktop != null) { } else { final ShadowElement se = this; ((ComponentCtrl) host).addCallback(AFTER_PAGE_ATTACHED, new Callback<Component>() { public void call(Component host) { host.getDesktop().getWebApp().getConfiguration().afterShadowAttached(se, host);
public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); Component rootParent = ComponentsCtrl.getRootParent(); final Radiogroup rg = getRadiogroup(); // ZK-3818: update selected index in the callback if (!_explictGroup) { _group = this.getRadiogroup(); } if (rg != null && rootParent instanceof ComponentCtrl && (!Components.isAncestor(rootParent, rg) || rootParent == rg)) { ((ComponentCtrl) rootParent).addCallback(AFTER_CHILD_ADDED, new Callback<Component>() { public void call(Component rootParent) { rg.fixOnAdd(Radio.this, false); } }); } } }
/** * Removes the relation points between shadow host and this shadow element. */ public void detach() { Component prevhost = getShadowHostIfAny(); if (_host != null) { ComponentCtrl host = (ComponentCtrl) _host; _host = null; // clear first to avoid endloop ((ComponentCtrl) host).removeShadowRoot(this); onHostDetached((Component) host); } setParent0(null); if (prevhost != null) { if (prevhost.getDesktop() != null) prevhost.getDesktop().getWebApp().getConfiguration().afterShadowDetached(this, prevhost); else { final ShadowElement se = this; ((ComponentCtrl) prevhost).addCallback(AFTER_PAGE_DETACHED, new Callback<Component>() { public void call(Component host) { host.getDesktop().getWebApp().getConfiguration().afterShadowDetached(se, host); } }); } } }
/** Returns the available children, or null if no cropping. */ private static Set<? extends Component> getAvailableAtClient(Component comp, Map<Component, Set<? extends Component>> croppingInfos) { final Object xc = ((ComponentCtrl) comp).getExtraCtrl(); if (xc instanceof Cropper) { //we don't need to check isCropper first since its component's job //to ensure the consistency Set<? extends Component> crop = croppingInfos.get(comp); if (crop == EMPTY_CROP) return null; if (crop != null) return crop; crop = ((Cropper) xc).getAvailableAtClient(); croppingInfos.put(comp, crop != null ? crop : EMPTY_CROP); return crop; } return null; }
public Object evaluate(XelContext ctx) throws XelException { try { if (cmp instanceof ComponentCtrl) { PropertyAccess propertyAccess = ((ComponentCtrl) cmp).getPropertyAccess(field); if (propertyAccess != null) return propertyAccess.getValue(cmp); } return Fields.get(cmp, field); } catch (NoSuchMethodException e) { if (cmp instanceof DynamicPropertied) { return ((DynamicPropertied) cmp).getDynamicProperty(field); } return null; } }
if (!((ComponentCtrl) rt).getShadowRoots().isEmpty() && seq.getId() != null) { //rt is shadow host and host id is given rt2 = (Component) ((ComponentCtrl) rt).getShadowFellowIfAny(seq.getId()); } else { continue;
public static List<String> getNonSystemProperties(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; List<String> props = compCtrl.getAnnotatedProperties(); if (props == null || props.size() == 0) return Collections.emptyList(); List<String> propsList = new ArrayList<String>(props.size()); for (String p : props) { if (p.startsWith(ZKBIND_PREFIX)) continue; propsList.add(p); } return propsList; }
final Component comp = wve.getComponent(); if (comp != null) { wve = ((ComponentCtrl) comp).onWrongValue(wve); if (wve != null) { Component c = wve.getComponent(); final Component comp = wve1.getComponent(); if (comp != null) { WrongValueException wve = ((ComponentCtrl) comp).onWrongValue(wve1); if (wve != null) { Component c = wve.getComponent();
/*package*/ ComponentMatchCtx(Component component, ComponentMatchCtx parent) { // first child _comp = component; int selectorListSize = parent._qualified.length; _qualified = new boolean[selectorListSize][]; for (int i = 0; i < selectorListSize; i++) _qualified[i] = new boolean[parent._qualified[i].length]; _parent = parent; _compChildIndex = 0; _isShadowHost = !((ComponentCtrl) component).getShadowRoots().isEmpty(); }
do { Component next = child.getNextSibling(); if (child instanceof Native || ((ComponentCtrl) child).getExtraCtrl() instanceof DirectContent) { ((ComponentCtrl) child).redraw(out); } else { HtmlPageRenders.setDirectContent(exec, false);
/** * @since 6.5.4 */ @SuppressWarnings("rawtypes") public static Annotation getSystemAnnotation(ComponentCtrl compCtrl, String propName) { //compatible to old spec, gets no ZKBIND prefix in annotation property first Collection<Annotation> annos = compCtrl.getAnnotations(propName, Binder.ZKBIND); if (annos.size() <= 0) { if (propName == null) return null; annos = compCtrl.getAnnotations(ZKBIND_PREFIX + propName, Binder.ZKBIND); if (annos.size() <= 0) return null; } //Use custom ZKBIND annotation instead of default ZKBIND annotation if any if (annos instanceof List) { return (Annotation) ((List) annos).get(0); } Iterator<Annotation> it = annos.iterator(); Annotation anno = it.next(); while (it.hasNext()) { anno = it.next(); } return anno; }
@Override public void onPageDetached(Page page) { super.onPageDetached(page); //B65-ZK-1768 remove the radio from the radiogroup in case it is an external radio final Radiogroup rg = getRadiogroup(); if (rg != null) { rg.removeExternal(this); } // ZK-3818: update selected index in the callback if (!_explictGroup) { _group = null; } Component rootParent = ComponentsCtrl.getRootParent(); if (rg != null && rootParent instanceof ComponentCtrl && (!Components.isAncestor(rootParent, rg) || rootParent == rg)) { ((ComponentCtrl) rootParent).addCallback(AFTER_CHILD_REMOVED, new Callback<Component>() { public void call(Component rootParent) { rg.fixOnRemove(Radio.this); } }); } }
public String getDynamicMediaURI(Component comp, String pathInfo) { if (!(((ComponentCtrl) comp).getExtraCtrl() instanceof DynamicMedia)) throw new UiException(DynamicMedia.class + " not implemented by getExtraCtrl() of " + comp); final StringBuffer sb = new StringBuffer(64).append("/view/").append(getId()).append('/').append(comp.getUuid()) .append('/'); Strings.encode(sb, System.identityHashCode(comp) & 0xffff); if (pathInfo != null && pathInfo.length() > 0) { if (pathInfo.charAt(0) != '/') sb.append('/'); sb.append(pathInfo); } return getUpdateURI(sb.toString()); }
public void setValue(XelContext ctx, Object value) throws XelException { try { if (cmp instanceof ComponentCtrl) { PropertyAccess propertyAccess = ((ComponentCtrl) cmp).getPropertyAccess(field); if (propertyAccess != null) { try { propertyAccess.setValue(cmp, Classes.coerce(propertyAccess.getType(), value)); return; // done } catch (ClassCastException cce) { // yes, ignore it here and use the old EL way. } } } Fields.set(cmp, field, value, true); } catch (NoSuchMethodException e) { if (cmp instanceof DynamicPropertied) { ((DynamicPropertied) cmp).setDynamicProperty(field, value); } } }