예제 #1
0
  public void afterCompose() {
    logger.debug("AssociationEditor, afterCompose()");

    // ((Borderlayout)getRoot()).setTitle(Labels.getLabel("common.associationEditor"));
    //    Radiogroup rgMode = (Radiogroup) getFellow("rgMode");
    //    rgMode.addEventListener(Events.ON_CHECK, new EventListener()
    //    {
    //      public void onEvent(Event event) throws Exception
    //      {
    ////                if(windowL != null && windowL.getWindowContentConcepts() != null)
    ////
    // windowL.getWindowContentConcepts().setAssociationMode(getAssociationMode());
    ////                if(windowR != null && windowR.getWindowContentConcepts() != null)
    ////
    // windowR.getWindowContentConcepts().setAssociationMode(getAssociationMode());
    //      }
    //    });
    //
    //
    Include incL = (Include) getFellow("incContentLeft");
    incL.setDynamicProperty("updateListener", this);
    incL.setDynamicProperty("associationEditor", this);
    incL.setSrc(null);
    incL.setSrc("/gui/main/content/ContentAssociationEditor.zul?id=1");

    for (Component comp : incL.getChildren()) {
      logger.debug("Comp: " + comp.getClass().getCanonicalName());
    }

    //    windowL = (ContentAssociationEditor) incL.getFellow("winAss");
    //    windowL.setUpdateListener(this);
    Include incR = (Include) getFellow("incContentRight");
    incR.setDynamicProperty("updateListener", this);
    incR.setDynamicProperty("associationEditor", this);
    incR.setSrc(null);
    incR.setSrc("/gui/main/content/ContentAssociationEditor.zul?id=2");
    //    windowR = (ContentAssociationEditor) incR.getFellow("winAss");
    //    windowR.setUpdateListener(this);

    fillAssociationTypeList();

    initList();
  }
예제 #2
0
  private void myLoadAttribute(Component comp, Object bean) {
    try {
      // since 3.1, 20080416, support bindingArgs for non-supported tag
      // bug #2803575, merge bindingArgs together since a component can have
      // multiple bindings on different attributes.
      Map<Object, Object> bindArgs = cast((Map) comp.getAttribute(DataBinder.ARGS));
      if (bindArgs == null) {
        bindArgs = new HashMap<Object, Object>();
        comp.setAttribute(DataBinder.ARGS, bindArgs);
      }
      if (_args != null) {
        bindArgs.putAll(_args);
        comp.setAttribute(_attr + "_" + DataBinder.ARGS, _args);
      }

      if (_converter != null) {
        bean = _converter.coerceToUi(bean, comp);
        if (bean == TypeConverter.IGNORE) return; // ignore, so don't do Fields.set()
      }

      // Bug #1876198 Error msg appears when load page (databind+CustomConstraint)
      // catching WrongValueException no longer works, check special case and
      // use setRowValue() method directly
      if ((comp instanceof InputElement) && "value".equals(_attr)) {
        Object value = bean;
        Object oldv = null;
        try { // Bug 1879389
          final Method m = comp.getClass().getMethod("getValue");
          oldv = ((InputElement) comp).getRawValue();
          value = Classes.coerce(m.getReturnType(), bean);
        } catch (NoSuchMethodException ex) { // ignore it
        }

        // See both Bug 3000305 and 2874098
        Fields.set(comp, "rawValue", value, _converter == null);
      } else {
        Fields.set(comp, _attr, bean, _converter == null);
      }
    } catch (ClassCastException ex) {
      throw UiException.Aide.wrap(ex);
    } catch (NoSuchMethodException ex) {
      // Bug #1813278, Annotations do not work with xhtml tags
      if (comp instanceof DynamicPropertied) {
        final DynamicPropertied dpcomp = (DynamicPropertied) comp;
        if (dpcomp.hasDynamicProperty(_attr)) {
          // no way to know destination type of the property, use bean as is
          dpcomp.setDynamicProperty(_attr, bean);
        } else {
          throw UiException.Aide.wrap(ex);
        }
      } else { // Feature# 2855116. Save into component custom-attribute(also a variable in ZK5).
        comp.setAttribute(_attr, bean);
      }

      // Bug #1876198 Error msg appears when load page (databind+CustomConstraint)
      // catching WrongValueException no longer works, so mark it out
      /*} catch (WrongValueException ex) {
      	//Bug #1615371, try to use setRawValue()
      	if ("value".equals(_attr)) {
      		try {
      			Fields.set(comp, "rawValue", bean, _converter == null);
      		} catch (Exception ex1) {
      			//exception
      			throw ex;
      		}
      	} else {
      		throw ex;
      	}
      */
    }
  }
예제 #3
0
 /**
  * This method will make the given component instance become a ZK Composite(an ZK MVC Controller).
  * <br>
  * If the instance's class(Composite class) has {@link Composite} annotation, this method will
  * based on the given meta to generate content children.<br>
  * If there's no proper zuml content provided, this method will assume the application developer
  * will assemble the content Component tree themselves.
  *
  * @since ZK 6.0
  * @param composite the composite instance that need to be processed
  * @param args ZK parser Context variables, the value inside can be accessed by EL[arg.varName] in
  *     zuml.(can be null)
  */
 public static void doCompose(Component composite, Map args) {
   CompositeDef def = DEF_CACHE.get(composite.getClass(), WebApps.getCurrent());
   doCompose(def, composite, composite, args);
 }