Ejemplo n.º 1
0
 /**
  * Binds the model and field. This method also updates the fields original value which controls
  * the dirty state of the field.
  *
  * @param model the model to be bound
  */
 public void bind(ModelData model) {
   if (this.model != null) {
     unbind();
   }
   this.model = model;
   field.addListener(Events.Change, changeListener);
   if (model instanceof Model) {
     ((Model) model).addChangeListener(modelListener);
   }
   updateField(updateOriginalValue);
 }
Ejemplo n.º 2
0
  /** Unbinds the model and field by removing all listeners. */
  public void unbind() {
    if (model != null) {
      if (model instanceof Model) {
        ((Model) model).removeChangeListener(modelListener);
      }
      model = null;
    }
    field.removeListener(Events.Change, changeListener);

    if (updateOriginalValue) {
      field.setOriginalValue(null);
    }
    field.clear();
  }