/** * Binds a field to a model. The {@link FieldModel} <em>must</em> belong to this {@link * FormModel}. * * <p>Adds a {@link AbstractModel} to this {@link AbstractModel}, so that the former is reverted, * checkpoint-ed, validated, bound, unbound, dirty-checked, etc. whenever this {@link * AbstractModel} is. * * @param field bound to the model. * @param model bound to the field. * @param binder used to bind the model and field. */ public <E> void bind(FieldModel<E> field, AbstractModel<E> model) { if (!field.getFormModel().equals(this)) { throw new IllegalArgumentException("field is not from this model"); } models.add(model); binder.bind(field).to(model.getMutableValueModel()); validationTree.add(model.validationTree); }