Exemple #1
0
  /** {@inheritDoc} */
  public final void update() {
    clearErrors();
    // do custom update
    doUpdate();

    // update binder
    binder.update();

    if (errors != null
        && binder.getBindingResult() != null
        && errors.getObjectName().equals(binder.getBindingResult().getObjectName()))
      errors.addAllErrors(binder.getBindingResult());

    // update subviews
    for (View<T> v : subViews) {
      v.update();
      if (errors != null
          && v.getBindingResult() != null
          && errors.getObjectName().equals(v.getBindingResult().getObjectName()))
        errors.addAllErrors(v.getBindingResult());
    }

    // allow subclasses to do something after the update
    afterUpdate();
  }
Exemple #2
0
  /** {@inheritDoc} */
  public void enableView(boolean enabled) {
    for (Binder<?> b : binder.getPropertyBinders()) {
      Object control = ((PropertyBinder) b).getComponent();

      if (control instanceof Component) ((Component) control).setEnabled(enabled);
      else if (control instanceof View<?>) ((View<?>) control).enableView(enabled);

      for (View<?> v : subViews) v.enableView(enabled);
    }
  }
Exemple #3
0
  /** {@inheritDoc} */
  public final void refresh() {
    clearErrors();
    doRefresh();
    binder.refresh();

    // refresh subviews
    for (View<T> v : subViews) v.refresh();

    setDirty(false);
  }
Exemple #4
0
  /** {@inheritDoc} */
  public final void setModel(T model) {
    this.model = model;
    createBindingResult();
    binder.setModel(model);

    // refresh subviews
    for (View<T> v : subViews) v.setModel(model);

    onSetModel(model);
  }
Exemple #5
0
  /** {@inheritDoc} */
  public boolean validateView() {
    if (validator == null && !errors.hasErrors()) return true;

    if (validator != null) validator.validate(getModel(), errors);

    if (errors.hasErrors()) {
      for (FieldError error : errors.getFieldErrors()) {
        for (ErrorProcessor ep : errorProcessors) {
          if (error instanceof ControlError) {
            ControlError ce = (ControlError) error;
            ep.processError(ce.getComponent(), error);
          } else {
            Binder<?> b = binder.getBinder(error.getField());
            if (b instanceof PropertyBinder) {
              ep.processError(((PropertyBinder) b).getComponent(), error);
            }
          }
        }
      }
      return false;
    }
    return true;
  }
Exemple #6
0
 /** {@inheritDoc} */
 public PropertyBinder getBinder(String propertyName) {
   return binder.getBinder(propertyName);
 }
Exemple #7
0
 /**
  * Sets the binder factory, propagate it to composite binder.
  *
  * @param binderFactory to set
  */
 public void setBinderFactory(BinderFactory binderFactory) {
   this.binderFactory = binderFactory;
   binder.setBinderFactory(binderFactory);
 }
Exemple #8
0
 /**
  * add a binding for control and model property name
  *
  * @param component control
  * @param propertyName the model property path to bind
  * @param readOnly if true, binding only do refresh()
  */
 public void bind(Object component, String propertyName, boolean readOnly) {
   checkFactories();
   binder.bind(component, propertyName, readOnly);
   listen(component);
 }