Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.Component


  private static abstract class BaseSaveEventListener extends BaseEventListener {
    public BaseSaveEventListener() {
      super();
    }
    protected void handleEvent(Event event) {
      final Component target = event.getTarget();
      final String triggerEventName = event.getName();
      final List tmplist = new ArrayList(_dataTargets.size());
     
      //fire onSave for each binding
      for(final Iterator it = _dataTargets.iterator();it.hasNext();) {
        final BindingInfo bi = (BindingInfo) it.next();
        final Component dt = bi.getComponent();
        final Binding binding = bi.getBinding();
        final DataBinder binder = binding.getBinder();
        final Component dataTarget = DataBinder.isTemplate(dt) ?
          DataBinder.lookupClone(target, dt) : dt;
        //bug# 1904389: NullPointerException if save-when in collection binding
        //event.getTarget() might not inside the collection item (i.e. row, listitem, etc.)
        //then binder.lookupClone() will return null dataTarget.
        if (dataTarget != null) {
          final Object[] vals = binding.getAttributeValues(dataTarget);
          if (vals != null) {
            tmplist.add(new BindingInfo(binding, dataTarget, vals));
            Events.sendEvent(new BindingSaveEvent("onBindingSave", dataTarget, target, binding, vals[0]));
          }
        } else {
          //bi.getComponent a template and a null dataTarget, meaning all collection items has to
          //be handled. Search the owner to iterate all cloned items.
          final List clones = scanClones(binder, dt);
          for (final Iterator itc = clones.iterator(); itc.hasNext();) {
            final Component dataTarget1 = (Component)itc.next();
            final Object[] vals = binding.getAttributeValues(dataTarget1);
            if (vals != null) {
              tmplist.add(new BindingInfo(binding, dataTarget1, vals));
              Events.sendEvent(new BindingSaveEvent("onBindingSave", dataTarget1, target, binding, vals[0]));
            }
          }
         
        }
      }
     
      //fire onValidate for target component
      Events.sendEvent(new Event("onBindingValidate", target));
     
      //saveAttribute for each binding
      Component loadOnSaveProxy = null;
      Component dataTarget = null;
      DataBinder binder = null;
      final List loadOnSaveInfos = new ArrayList(tmplist.size());
      for(final Iterator it = tmplist.iterator();it.hasNext();) {
        final BindingInfo bi = (BindingInfo) it.next();
        dataTarget = bi.getComponent();
        final Binding binding = bi.getBinding();
        if (binder == null) {
          binder = binding.getBinder();
        }
        final Object[] vals = bi.getAttributeValues();
        binding.saveAttributeValue(dataTarget, vals, loadOnSaveInfos, triggerEventName);
        if (loadOnSaveProxy == null && dataTarget.isListenerAvailable("onLoadOnSave", true)) {
          loadOnSaveProxy = dataTarget;
        }
      }
     
      //bug #1895856 : data binding LoadOnSave works only on the last save-when component
View Full Code Here


    }

    final Iterator itt = template.getChildren().iterator();
    final Iterator itc = clone.getChildren().iterator();
    while (itt.hasNext()) {
      final Component t = (Component) itt.next();
      final Component c = (Component) itc.next();
      linkTemplates(c, t, templatemap)//recursive
    }
  }
View Full Code Here

    //Listbox in Listbox, Listbox in Grid, Grid in Listbox, Grid in Grid,
    //no need to process down since BindingRowRenderer of the under Grid
    //owner will do its own setupCloneIds()
    //bug #1893247: Not unique in the new ID space when Grid in Grid
    final Component template = DataBinder.getComponent(clone);
    if (template != null && DataBinder.isCollectionOwner(template)) {
      return;
    }
   
    for(final Iterator it = clone.getChildren().iterator(); it.hasNext(); ) {
View Full Code Here

  }

  /** Returns the tree that this belongs to.
   */
  public Tree getTree() {
    final Component comp = getParent();
    return comp != null ? (Tree)comp.getParent(): null;
  }
View Full Code Here

  public Collection getComponents() {
    return _comps.values();
  }
  public Component getComponentByUuid(String uuid) {
    final Component comp = (Component)_comps.get(uuid);
    if (comp == null)
      throw new ComponentNotFoundException("Component not found: "+uuid);
    return comp;
  }
View Full Code Here

            return; //done
        }
      }
    }

    final Component comp = request.getComponent();
    if (comp != null) {
      final AuService svc = comp.getAuService();
      if (svc == null || !svc.service(request, everError))
        ((ComponentCtrl)comp).service(request, everError);
      return; //done (it's comp's job to handle it)
    }
View Full Code Here

    ((PageCtrl)page).destroy();
  }
  private void removeComponents(Collection comps) {
    for (Iterator it = comps.iterator(); it.hasNext();) {
      final Component comp = (Component)it.next();
      removeComponents(comp.getChildren()); //recursive
      removeComponent(comp, true);
    }
  }
View Full Code Here

    private static final long serialVersionUID = 200808191534L;
  public Object coerceToUi(Object val, Component comp) { //load
    if (val != null) {
      //iterate to find the selected radio via the value
      for (Iterator it = comp.getChildren().iterator(); it.hasNext();) {
        final Component child = (Component)it.next();
        if (child instanceof Radio) {
          if (val.equals(((Radio)child).getValue())) {
            return child;
          }
        } else if (!(child instanceof Radiogroup)) { //skip nested radiogroup
View Full Code Here

          targetlang = _zslang; //use default

        if (targetlang.equalsIgnoreCase(zslang)) { //case insensitive
          it.remove(); //done

          final Component parent = (Component)zsInfo[0];
          if ((parent == null || parent.getPage() == this)
          && isEffective(zscript, parent)) {
            final Scope scope =
              Scopes.beforeInterpret(parent != null ? (Scope)parent: this);
            try {
              ip.interpret(zscript.getContent(this, parent), scope);
View Full Code Here

  }

  /** Returns the tree that it belongs to.
   */
  public Tree getTree() {
    final Component comp = getParent();
    return comp != null ? (Tree)comp.getParent(): null;
  }
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.Component

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.