/** * 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); }
/** 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(); }