From 7f733bc2aab41963a9ef44be252f3ee2462fa70a Mon Sep 17 00:00:00 2001 From: Tatu Lund Date: Fri, 20 Dec 2019 12:47:24 +0200 Subject: Added documentation of newly added Binder features (#11845) --- documentation/datamodel/datamodel-forms.asciidoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/documentation/datamodel/datamodel-forms.asciidoc b/documentation/datamodel/datamodel-forms.asciidoc index fc4572f97c..0061304c68 100644 --- a/documentation/datamodel/datamodel-forms.asciidoc +++ b/documentation/datamodel/datamodel-forms.asciidoc @@ -138,6 +138,7 @@ binder.forField(nameField) binder.forField(titleField) // Shorthand for requiring the field to be non-empty + // This is conditional on Binding::setAsRequiredEnabled(boolean) .asRequired("Every employee must have a title") .bind(Person::getTitle, Person::setTitle); ---- @@ -382,6 +383,11 @@ if (saved) { ---- -- +[NOTE] +Note, if you need to write the values passing the validation regardless of having one or more failing validators, you can +use binder.writeBeanAsDraft(person). + + Binder keeps track of which bindings have been updated by the user and which bindings are in an invalid state. It also fires an event when this status changes. We can use that event to make the save and reset buttons of our forms become enabled or disabled depending on the current status of the form. @@ -612,3 +618,10 @@ binder.forField(yearOfBirth) binder.bindInstanceFields(this); ---- + +[NOTE] +If you need to bind nested proprerties with bindInstanceFields method, you need to instantiate the Binder using: +[source,java] +---- +Binder binder = new Binder<>(Person.class,true); +---- -- cgit v1.2.3