summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--documentation/datamodel/datamodel-forms.asciidoc46
-rw-r--r--server/src/main/java/com/vaadin/data/Binder.java198
-rw-r--r--server/src/main/java/com/vaadin/data/StatusChangeEvent.java26
-rw-r--r--server/src/main/java/com/vaadin/data/ValidationException.java6
-rw-r--r--server/src/test/java/com/vaadin/data/BeanBinderInstanceFieldTest.java18
-rw-r--r--server/src/test/java/com/vaadin/data/BeanBinderTest.java22
-rw-r--r--server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java38
-rw-r--r--server/src/test/java/com/vaadin/data/BinderComponentTest.java2
-rw-r--r--server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java72
-rw-r--r--server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java16
-rw-r--r--server/src/test/java/com/vaadin/data/BinderSingleSelectTest.java8
-rw-r--r--server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java88
-rw-r--r--server/src/test/java/com/vaadin/data/BinderTest.java51
-rw-r--r--server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java4
-rw-r--r--server/src/test/java/com/vaadin/data/Jsr303Test.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java6
18 files changed, 309 insertions, 302 deletions
diff --git a/documentation/datamodel/datamodel-forms.asciidoc b/documentation/datamodel/datamodel-forms.asciidoc
index f34bae1aa2..b82c1b7619 100644
--- a/documentation/datamodel/datamodel-forms.asciidoc
+++ b/documentation/datamodel/datamodel-forms.asciidoc
@@ -45,12 +45,12 @@ When we have bound field components using our binder, we can use the binder to l
Person person = new Person("John Doe", 1957);
// Updates the value in each bound field component
-binder.load(person);
+binder.readBean(person);
Button saveButton = new Button("Save",
event -> {
try {
- binder.save(person);
+ binder.writeBean(person);
// A real application would also save the updated person
// using the application's backend
} catch (BindingException e) {
@@ -61,7 +61,7 @@ Button saveButton = new Button("Save",
// Updates the fields again with the previously saved values
Button resetButton = new Button("Reset",
- event -> binder.load(person));
+ event -> binder.readBean(person));
----
With these basic steps, we have defined everything that is needed for loading, editing and saving values for a form.
@@ -319,7 +319,7 @@ Even if the user has not edited a field, all validation error will be shown if w
[source, java]
----
// Resets the form to show default values by populating the fields with the default values from the bean
-binder.load(new Person());
+binder.readBean(new Person());
// This will make all current validation errors visible
ValidationStatus<Person> status = binder.validate();
@@ -339,7 +339,7 @@ Handling a checked exception::
[source, java]
----
try {
- binder.save(person);
+ binder.writeBean(person);
} catch (ValidationException e) {
Notification.show("Validation error count: "
+ e.getValidationErrors().size());
@@ -352,7 +352,7 @@ Defining an error handler when saving::
--
[source, java]
----
-binder.save(person,
+binder.writeBean(person,
// Callback invoked if there is an error
errors -> {
Notification.show("Validation error count: "
@@ -367,7 +367,7 @@ Checking a return value::
--
[source, java]
----
-boolean saved = binder.saveIfValid(person);
+boolean saved = binder.writeBeanIfValid(person);
if (!saved) {
Notification.show("Validation error count: "
+ binder.getValidationErrors().size());
@@ -399,7 +399,7 @@ This is useful for creating a user interface where changes are saved immediately
----
// Invoked when the value of any bound field component changes
binder.addFieldValueChangeListener(event -> {
- if (binder.saveIfValid(person)) {
+ if (binder.writeBeanIfValid(person)) {
// We only get here if there are no validation errors
// TODO: Do something with the updated person instance
@@ -414,7 +414,7 @@ If we want all the fields to work independently of each other, we can instead sa
----
binder.addFieldValueChangeListener(event -> {
Binding<Person, ?> binding = event.getBinding();
- if (binding.saveIfValid(person)) {
+ if (binder.writeIfValid(person)) {
// We get here if the updated binding had no validation errors
// TODO: Do something with the updated person instance
@@ -437,7 +437,7 @@ Person person = new Person("John Doe", 1957);
// Loads the values from the person instance
// Sets person to be updated when any bound field is updated
-binder.bind(person);
+binder.setBean(person);
Button saveButton = new Button("Save", event -> {
if (binder.isValid()) {
@@ -453,24 +453,6 @@ Button saveButton = new Button("Save", event -> {
When using the [methodname]#bind# method, the business object instance will be updated whenever the user changes the value in any bound field.
If some other part of the application is also using the same instance, then that part might show changes before the user has clicked the save button.
-The [methodname]#bind# method returns an [interfacename]#ItemBinding# instance that we can use to further configure the binding.
-We can change the binding to use a different business object, cancel the binding, or change whether a validation error prevents other values from being saved.
-
-[source, java]
-----
-ItemBinding<Person> binding = binder.bind(person);
-
-// Makes the binding save new values for valid fields even if
-// other fields are invalid
-binding.setSaveWhenInvalid(true);
-
-// Field changes will update anotherPerson instead of person
-binding.bind(anotherPerson);
-
-// Field changes will no longer update any person instance
-binding.cancel();
-----
-
== Binding Beans to Forms
The business objects used in an application are in most cases implemented as Java beans.
@@ -612,12 +594,12 @@ binder.forField(phoneField).bind("phone");
Person person = // e.g. JPA entity or bean from Grid
// Load person data to a form
-binder.load(person);
+binder.readBean(person);
Button saveButton = new Button("Save", event -> {
// Using saveIfValid to avoid the try-catch block that is
// needed if using the regular save method
- if (binder.saveIfValid(person)) {
+ if (binder.writeBeanIfValid(person)) {
// Person is valid and updated
// TODO Store in the database
}
@@ -672,10 +654,10 @@ public class PersonForm extends PersonFormDesign {
public PersonForm(Person person) {
binder.bindInstanceFields(this);
- binder.load(person);
+ binder.readBean(person);
save.addClickListener(event -> {
- if (binder.saveIfValid(person)) {
+ if (binder.writeBeanIfValid(person)) {
// TODO: Do something with the updated person instance
}
});
diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java
index 138ec12b00..effd315ab3 100644
--- a/server/src/main/java/com/vaadin/data/Binder.java
+++ b/server/src/main/java/com/vaadin/data/Binder.java
@@ -63,14 +63,14 @@ import com.vaadin.ui.UI;
* Bean level validators can be added using the
* {@link #withValidator(Validator)} method and will be run on the bound bean
* once it has been updated from the values of the bound fields. Bean level
- * validators are also run as part of {@link #save(Object)} and
- * {@link #saveIfValid(Object)} if all field level validators pass.
+ * validators are also run as part of {@link #writeBean(Object)} and
+ * {@link #writeBeanIfValid(Object)} if all field level validators pass.
* <p>
* Note: For bean level validators, the bean must be updated before the
- * validators are run. If a bean level validator fails in {@link #save(Object)}
- * or {@link #saveIfValid(Object)}, the bean will be reverted to the previous
- * state before returning from the method. You should ensure that the
- * getters/setters in the bean do not have side effects.
+ * validators are run. If a bean level validator fails in
+ * {@link #writeBean(Object)} or {@link #writeBeanIfValid(Object)}, the bean
+ * will be reverted to the previous state before returning from the method. You
+ * should ensure that the getters/setters in the bean do not have side effects.
* <p>
* Unless otherwise specified, {@code Binder} method arguments cannot be null.
*
@@ -107,11 +107,11 @@ public class Binder<BEAN> implements Serializable {
* update the field value from the property and to store the field value
* to the property, respectively.
* <p>
- * When a bean is bound with {@link Binder#bind(BEAN)}, the field value
- * is set to the return value of the given getter. The property value is
- * then updated via the given setter whenever the field value changes.
- * The setter may be null; in that case the property value is never
- * updated and the binding is said to be <i>read-only</i>.
+ * When a bean is bound with {@link Binder#setBean(BEAN)}, the field
+ * value is set to the return value of the given getter. The property
+ * value is then updated via the given setter whenever the field value
+ * changes. The setter may be null; in that case the property value is
+ * never updated and the binding is said to be <i>read-only</i>.
* <p>
* If the Binder is already bound to some bean, the newly bound field is
* associated with the corresponding bean property as described above.
@@ -135,7 +135,7 @@ public class Binder<BEAN> implements Serializable {
* the function to get the value of the property to the
* field, not null
* @param setter
- * the function to save the field value to the property or
+ * the function to write the field value to the property or
* null if read-only
* @throws IllegalStateException
* if {@code bind} has already been called on this binding
@@ -145,7 +145,7 @@ public class Binder<BEAN> implements Serializable {
/**
* Adds a validator to this binding. Validators are applied, in
- * registration order, when the field value is saved to the backing
+ * registration order, when the field value is written to the backing
* property. If any validator returns a failure, the property value is
* not updated.
*
@@ -163,8 +163,8 @@ public class Binder<BEAN> implements Serializable {
* {@link Validator#from(SerializablePredicate, String)} factory method.
* <p>
* Validators are applied, in registration order, when the field value
- * is saved to the backing property. If any validator returns a failure,
- * the property value is not updated.
+ * is written to the backing property. If any validator returns a
+ * failure, the property value is not updated.
*
* @see #withValidator(Validator)
* @see Validator#from(SerializablePredicate, String)
@@ -500,9 +500,9 @@ public class Binder<BEAN> implements Serializable {
* <p>
* The method {@link #withConverter(Converter)} calls this method with
* {@code true} provided as the second argument value.
- *
+ *
* @see #withConverter(Converter)
- *
+ *
* @param converter
* the converter to use, not null
* @param resetNullRepresentation
@@ -613,7 +613,7 @@ public class Binder<BEAN> implements Serializable {
return new ValueContext(findLocale());
}
- private void unbind() {
+ private void reset() {
onValueChange.remove();
}
@@ -643,7 +643,7 @@ public class Binder<BEAN> implements Serializable {
private void handleFieldValueChange(BEAN bean) {
getBinder().setHasChanges(true);
// store field value if valid
- ValidationStatus<TARGET> fieldValidationStatus = storeFieldValue(
+ ValidationStatus<TARGET> fieldValidationStatus = writeFieldValue(
bean);
List<Result<?>> binderValidationResults;
// if all field level validations pass, run bean level validation
@@ -661,13 +661,13 @@ public class Binder<BEAN> implements Serializable {
}
/**
- * Saves the field value by invoking the setter function on the given
+ * Write the field value by invoking the setter function on the given
* bean, if the value passes all registered validators.
*
* @param bean
* the bean to set the property value to
*/
- private ValidationStatus<TARGET> storeFieldValue(BEAN bean) {
+ private ValidationStatus<TARGET> writeFieldValue(BEAN bean) {
assert bean != null;
ValidationStatus<TARGET> validationStatus = doValidation();
@@ -838,11 +838,11 @@ public class Binder<BEAN> implements Serializable {
* {@link #forField(HasValue)} and
* {@link Binding#withNullRepresentation(Object))}.
* <p>
- * When a bean is bound with {@link Binder#bind(BEAN)}, the field value is
- * set to the return value of the given getter. The property value is then
- * updated via the given setter whenever the field value changes. The setter
- * may be null; in that case the property value is never updated and the
- * binding is said to be <i>read-only</i>.
+ * When a bean is bound with {@link Binder#setBean(BEAN)}, the field value
+ * is set to the return value of the given getter. The property value is
+ * then updated via the given setter whenever the field value changes. The
+ * setter may be null; in that case the property value is never updated and
+ * the binding is said to be <i>read-only</i>.
* <p>
* If the Binder is already bound to some bean, the newly bound field is
* associated with the corresponding bean property as described above.
@@ -870,7 +870,7 @@ public class Binder<BEAN> implements Serializable {
* the function to get the value of the property to the field,
* not null
* @param setter
- * the function to save the field value to the property or null
+ * the function to write the field value to the property or null
* if read-only
*/
public <FIELDVALUE> void bind(HasValue<FIELDVALUE> field,
@@ -880,8 +880,8 @@ public class Binder<BEAN> implements Serializable {
}
/**
- * Binds the given bean to all the fields added to this Binder. To remove
- * the binding, call {@link #unbind()}.
+ * Binds the given bean to all the fields added to this Binder. A
+ * {@code null} value removes a currently bound bean.
* <p>
* When a bean is bound, the field values are updated by invoking their
* corresponding getter functions. Any changes to field values are reflected
@@ -892,31 +892,39 @@ public class Binder<BEAN> implements Serializable {
* {@link Binding} and bean level validation for this binder (bean level
* validators are added using {@link Binder#withValidator(Validator)}.
*
- * @see #load(Object)
- * @see #save(Object)
- * @see #saveIfValid(Object)
+ * @see #readBean(Object)
+ * @see #writeBean(Object)
+ * @see #writeBeanIfValid(Object)
*
* @param bean
- * the bean to edit, not null
+ * the bean to edit, or {@code null} to remove a currently bound
+ * bean
*/
- public void bind(BEAN bean) {
- Objects.requireNonNull(bean, "bean cannot be null");
- doUnbind(false);
- this.bean = bean;
- bindings.forEach(b -> b.bind(bean));
- // if there has been field value change listeners that trigger
- // validation, need to make sure the validation errors are cleared
- getValidationStatusHandler()
- .accept(BinderValidationStatus.createUnresolvedStatus(this));
- fireStatusChangeEvent(false);
+ public void setBean(BEAN bean) {
+ if (bean == null) {
+ if (this.bean != null) {
+ doRemoveBean(true);
+ }
+ } else {
+ doRemoveBean(false);
+ this.bean = bean;
+ bindings.forEach(b -> b.bind(bean));
+ // if there has been field value change listeners that trigger
+ // validation, need to make sure the validation errors are cleared
+ getValidationStatusHandler().accept(
+ BinderValidationStatus.createUnresolvedStatus(this));
+ fireStatusChangeEvent(false);
+ }
}
/**
- * Unbinds the currently bound bean if any. If there is no bound bean, does
+ * Removes the currently set bean, if any. If there is no bound bean, does
* nothing.
+ * <p>
+ * This is a shorthand for {@link #setBean(Object)} with {@code null} bean.
*/
- public void unbind() {
- doUnbind(true);
+ public void removeBean() {
+ setBean(null);
}
/**
@@ -925,16 +933,16 @@ public class Binder<BEAN> implements Serializable {
* <p>
* The bean is not otherwise associated with this binder; in particular its
* property values are not bound to the field value changes. To achieve
- * that, use {@link #bind(BEAN)}.
+ * that, use {@link #setBean(BEAN)}.
*
- * @see #bind(Object)
- * @see #saveIfValid(Object)
- * @see #save(Object)
+ * @see #setBean(Object)
+ * @see #writeBeanIfValid(Object)
+ * @see #writeBean(Object)
*
* @param bean
* the bean whose property values to read, not null
*/
- public void load(BEAN bean) {
+ public void readBean(BEAN bean) {
Objects.requireNonNull(bean, "bean cannot be null");
setHasChanges(false);
bindings.forEach(binding -> binding.setFieldValue(bean));
@@ -945,10 +953,10 @@ public class Binder<BEAN> implements Serializable {
}
/**
- * Saves changes from the bound fields to the given bean if all validators
+ * Writes changes from the bound fields to the given bean if all validators
* (binding and bean level) pass.
* <p>
- * If any field binding validator fails, no values are saved and a
+ * If any field binding validator fails, no values are written and a
* {@code ValidationException} is thrown.
* <p>
* If all field level validators pass, the given bean is updated and bean
@@ -956,17 +964,18 @@ public class Binder<BEAN> implements Serializable {
* fails, the bean updates are reverted and a {@code ValidationException} is
* thrown.
*
- * @see #saveIfValid(Object)
- * @see #load(Object)
- * @see #bind(Object)
+ * @see #writeBeanIfValid(Object)
+ * @see #readBean(Object)
+ * @see #setBean(Object)
*
* @param bean
- * the object to which to save the field values, not null
+ * the object to which to write the field values, not
+ * {@code null}
* @throws ValidationException
* if some of the bound field values fail to validate
*/
- public void save(BEAN bean) throws ValidationException {
- BinderValidationStatus<BEAN> status = doSaveIfValid(bean);
+ public void writeBean(BEAN bean) throws ValidationException {
+ BinderValidationStatus<BEAN> status = doWriteIfValid(bean);
if (status.hasErrors()) {
throw new ValidationException(status.getFieldValidationErrors(),
status.getBeanValidationErrors());
@@ -974,40 +983,41 @@ public class Binder<BEAN> implements Serializable {
}
/**
- * Saves changes from the bound fields to the given bean if all validators
+ * Writes changes from the bound fields to the given bean if all validators
* (binding and bean level) pass.
* <p>
- * If any field binding validator fails, no values are saved and
+ * If any field binding validator fails, no values are written and
* <code>false</code> is returned.
* <p>
* If all field level validators pass, the given bean is updated and bean
* level validators are run on the updated bean. If any bean level validator
* fails, the bean updates are reverted and <code>false</code> is returned.
*
- * @see #save(Object)
- * @see #load(Object)
- * @see #bind(Object)
+ * @see #writeBean(Object)
+ * @see #readBean(Object)
+ * @see #setBean(Object)
*
* @param bean
- * the object to which to save the field values, not null
+ * the object to which to write the field values, not
+ * {@code null}
* @return {@code true} if there was no validation errors and the bean was
* updated, {@code false} otherwise
*/
- public boolean saveIfValid(BEAN bean) {
- return doSaveIfValid(bean).isOk();
+ public boolean writeBeanIfValid(BEAN bean) {
+ return doWriteIfValid(bean).isOk();
}
/**
- * Saves the field values into the given bean if all field level validators
- * pass. Runs bean level validators on the bean after saving.
+ * Writes the field values into the given bean if all field level validators
+ * pass. Runs bean level validators on the bean after writing.
*
* @param bean
- * the bean to save field values into
+ * the bean to write field values into
* @return a list of field validation errors if such occur, otherwise a list
* of bean validation errors.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
- private BinderValidationStatus<BEAN> doSaveIfValid(BEAN bean) {
+ private BinderValidationStatus<BEAN> doWriteIfValid(BEAN bean) {
Objects.requireNonNull(bean, "bean cannot be null");
// First run fields level validation
List<ValidationStatus<?>> bindingStatuses = validateBindings();
@@ -1019,12 +1029,12 @@ public class Binder<BEAN> implements Serializable {
Collections.emptyList());
}
- // Save old bean values so we can restore them if validators fail
+ // Store old bean values so we can restore them if validators fail
Map<Binding<BEAN, ?, ?>, Object> oldValues = new HashMap<>();
bindings.forEach(
binding -> oldValues.put(binding, binding.getter.apply(bean)));
- bindings.forEach(binding -> binding.storeFieldValue(bean));
+ bindings.forEach(binding -> binding.writeFieldValue(bean));
// Now run bean level validation against the updated bean
List<Result<?>> binderResults = validateBean(bean);
boolean hasErrors = binderResults.stream().filter(Result::isError)
@@ -1034,7 +1044,7 @@ public class Binder<BEAN> implements Serializable {
bindings.forEach((BindingImpl binding) -> binding.setter
.accept(bean, oldValues.get(binding)));
} else {
- // Save successful, reset hasChanges to false
+ // Write successful, reset hasChanges to false
setHasChanges(false);
}
fireStatusChangeEvent(hasErrors);
@@ -1049,8 +1059,8 @@ public class Binder<BEAN> implements Serializable {
* updated. If the validators fail, the bean instance is reverted to its
* previous state.
*
- * @see #save(Object)
- * @see #saveIfValid(Object)
+ * @see #writeBean(Object)
+ * @see #writeBeanIfValid(Object)
*
* @param validator
* the validator to add, not null
@@ -1066,7 +1076,7 @@ public class Binder<BEAN> implements Serializable {
* Validates the values of all bound fields and returns the validation
* status.
* <p>
- * If all field level validators pass, and {@link #bind(Object)} has been
+ * If all field level validators pass, and {@link #setBean(Object)} has been
* used to bind to a bean, bean level validators are run for that bean. Bean
* level validators are ignored if there is no bound bean or if any field
* level validator fails.
@@ -1218,20 +1228,21 @@ public class Binder<BEAN> implements Serializable {
* happens:
* <ul>
* <li>if it's bound and any of its bound field or select has been changed
- * <li>{@link #save(Object)} or {@link #saveIfValid(Object)} is called
- * <li>{@link #load(Object)} is called
- * <li>{@link #bind(Object)} is called
- * <li>{@link #unbind(Object)} is called
+ * <li>{@link #writeBean(Object)} or {@link #writeBeanIfValid(Object)} is
+ * called
+ * <li>{@link #readBean(Object)} is called
+ * <li>{@link #setBean(Object)} is called
+ * <li>{@link #removeBean()} is called
* <li>{@link Binding#bind(SerializableFunction, SerializableBiConsumer)} is
* called
* <li>{@link Binder#validate()} or {@link Binding#validate()} is called
* </ul>
*
- * @see #load(Object)
- * @see #save(Object)
- * @see #saveIfValid(Object)
- * @see #bind(Object)
- * @see #unbind()
+ * @see #readBean(Object)
+ * @see #writeBean(Object)
+ * @see #writeBeanIfValid(Object)
+ * @see #setBean(Object)
+ * @see #removeBean()
* @see #forField(HasValue)
* @see #forSelect(AbstractMultiSelect)
* @See {@link #validate()}
@@ -1287,7 +1298,7 @@ public class Binder<BEAN> implements Serializable {
}
/**
- * Handles a validation error emitted when trying to save the value of the
+ * Handles a validation error emitted when trying to write the value of the
* given field. The default implementation sets the
* {@link AbstractComponent#setComponentError(ErrorMessage) component error}
* of the field if it is a Component, otherwise does nothing.
@@ -1356,7 +1367,7 @@ public class Binder<BEAN> implements Serializable {
/**
* Sets whether the values of the fields this binder is bound to have
- * changed since the last explicit call to either bind, save or load.
+ * changed since the last explicit call to either bind, write or read.
*
* @param hasChanges
* whether this binder should be marked to have changes
@@ -1367,11 +1378,12 @@ public class Binder<BEAN> implements Serializable {
/**
* Check whether any of the bound fields' values have changed since last
- * explicit call to bind, save or load. Unsuccessful save operations will
- * not affect this value.
+ * explicit call to {@link #setBean(Object)}, {@link #writeBean(Object)} or
+ * {@link #readBean(Object)}. Unsuccessful write operations will not affect
+ * this value.
*
* @return whether any bound field's value has changed since last call to
- * bind, save or load
+ * setBean, writeBean or readBean
*/
public boolean hasChanges() {
return hasChanges;
@@ -1389,11 +1401,11 @@ public class Binder<BEAN> implements Serializable {
return eventRouter;
}
- private void doUnbind(boolean fireStatusEvent) {
+ private void doRemoveBean(boolean fireStatusEvent) {
setHasChanges(false);
if (bean != null) {
bean = null;
- bindings.forEach(BindingImpl::unbind);
+ bindings.forEach(BindingImpl::reset);
}
getValidationStatusHandler()
.accept(BinderValidationStatus.createUnresolvedStatus(this));
diff --git a/server/src/main/java/com/vaadin/data/StatusChangeEvent.java b/server/src/main/java/com/vaadin/data/StatusChangeEvent.java
index 7a73fb5150..076b4a4a4d 100644
--- a/server/src/main/java/com/vaadin/data/StatusChangeEvent.java
+++ b/server/src/main/java/com/vaadin/data/StatusChangeEvent.java
@@ -16,10 +16,10 @@
package com.vaadin.data;
import java.util.EventObject;
-import java.util.function.BiConsumer;
-import java.util.function.Function;
import com.vaadin.data.Binder.Binding;
+import com.vaadin.server.SerializableBiConsumer;
+import com.vaadin.server.SerializableFunction;
/**
* Binder status change event.
@@ -27,17 +27,19 @@ import com.vaadin.data.Binder.Binding;
* The {@link Binder} status is changed whenever any of the following happens:
* <ul>
* <li>if it's bound and any of its bound field or select has been changed
- * <li>{@link #save(Object)} or {@link #saveIfValid(Object)} is called
- * <li>{@link #load(Object)} is called
- * <li>{@link #bind(Object)} is called
- * <li>{@link #unbind(Object)} is called
- * <li>{@link Binding#bind(Function, BiConsumer)} is called
+ * <li>{@link Binder#writeBean(Object)} or
+ * {@link Binder#writeBeanIfValid(Object)} is called
+ * <li>{@link Binder#readBean(Object)} is called
+ * <li>{@link Binder#setBean(Object)} is called
+ * <li>{@link Binder#removeBean()} is called
+ * <li>{@link Binding#bind(SerializableFunction, SerializableBiConsumer)} is
+ * called
* <li>{@link Binder#validate()} or {@link Binding#validate()} is called
* </ul>
- *
+ *
* @see StatusChangeListener#statusChange(StatusChangeEvent)
* @see Binder#addStatusChangeListener(StatusChangeListener)
- *
+ *
* @author Vaadin Ltd
*
*/
@@ -48,7 +50,7 @@ public class StatusChangeEvent extends EventObject {
/**
* Create a new status change event for given {@code binder} using its
* current validation status.
- *
+ *
* @param binder
* the event source binder
* @param hasValidationErrors
@@ -61,7 +63,7 @@ public class StatusChangeEvent extends EventObject {
/**
* Gets the binder validation status.
- *
+ *
* @return {@code true} if the binder has validation errors, {@code false}
* otherwise
*/
@@ -76,7 +78,7 @@ public class StatusChangeEvent extends EventObject {
/**
* Gets the binder.
- *
+ *
* @return the binder
*/
public Binder<?> getBinder() {
diff --git a/server/src/main/java/com/vaadin/data/ValidationException.java b/server/src/main/java/com/vaadin/data/ValidationException.java
index 354420a41c..093d88283a 100644
--- a/server/src/main/java/com/vaadin/data/ValidationException.java
+++ b/server/src/main/java/com/vaadin/data/ValidationException.java
@@ -21,9 +21,11 @@ import java.util.List;
import java.util.stream.Collectors;
/**
- * Indicates validation errors in a {@link Binder} when save is requested.
+ * Indicates validation errors in a {@link Binder} when a field value is
+ * validated.
*
- * @see Binder#save(Object)
+ * @see Binder#writeBean(Object)
+ * @see Binder#writeBeanIfValid(Object)
*
* @author Vaadin Ltd
* @since 8.0
diff --git a/server/src/test/java/com/vaadin/data/BeanBinderInstanceFieldTest.java b/server/src/test/java/com/vaadin/data/BeanBinderInstanceFieldTest.java
index 37b328f97c..c202dbb47f 100644
--- a/server/src/test/java/com/vaadin/data/BeanBinderInstanceFieldTest.java
+++ b/server/src/test/java/com/vaadin/data/BeanBinderInstanceFieldTest.java
@@ -139,7 +139,7 @@ public class BeanBinderInstanceFieldTest {
person.setFirstName("foo");
person.setBirthDate(LocalDate.now());
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(person.getFirstName(), form.firstName.getValue());
Assert.assertEquals(person.getBirthDate(), form.birthDate.getValue());
@@ -160,7 +160,7 @@ public class BeanBinderInstanceFieldTest {
Person person = new Person();
person.setFirstName("foo");
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(person.getFirstName(), form.firstName.getValue());
@@ -180,7 +180,7 @@ public class BeanBinderInstanceFieldTest {
Person person = new Person();
person.setFirstName("foo");
- binder.bind(person);
+ binder.setBean(person);
Assert.assertNull(form.firstName);
}
@@ -194,7 +194,7 @@ public class BeanBinderInstanceFieldTest {
Person person = new Person();
person.setFirstName("foo");
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(person.getFirstName(), form.firstName.getValue());
@@ -254,7 +254,7 @@ public class BeanBinderInstanceFieldTest {
Person person = new Person();
person.setFirstName("foo");
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(person.getFirstName(), form.firstName.getValue());
@@ -276,7 +276,7 @@ public class BeanBinderInstanceFieldTest {
Person person = new Person();
person.setFirstName("foo");
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(name, form.firstName);
}
@@ -291,7 +291,7 @@ public class BeanBinderInstanceFieldTest {
person.setFirstName("foo");
person.setBirthDate(LocalDate.now());
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(person.getFirstName(), form.nameField.getValue());
Assert.assertEquals(person.getBirthDate(),
@@ -324,7 +324,7 @@ public class BeanBinderInstanceFieldTest {
person.setFirstName(personName);
person.setBirthDate(LocalDate.now());
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(person.getFirstName(), form.firstName.getValue());
Assert.assertEquals(person.getBirthDate(), form.birthDate.getValue());
@@ -365,7 +365,7 @@ public class BeanBinderInstanceFieldTest {
person.setFirstName(personName);
person.setAge(age);
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(person.getFirstName(), form.firstName.getValue());
Assert.assertEquals(String.valueOf(person.getAge()),
diff --git a/server/src/test/java/com/vaadin/data/BeanBinderTest.java b/server/src/test/java/com/vaadin/data/BeanBinderTest.java
index 17b66ddbb9..117b4e81eb 100644
--- a/server/src/test/java/com/vaadin/data/BeanBinderTest.java
+++ b/server/src/test/java/com/vaadin/data/BeanBinderTest.java
@@ -24,14 +24,14 @@ public class BeanBinderTest
@Test
public void fieldBound_bindBean_fieldValueUpdated() {
binder.bind(nameField, "firstname");
- binder.bind(item);
+ binder.setBean(item);
assertEquals("Johannes", nameField.getValue());
}
@Test
public void beanBound_bindField_fieldValueUpdated() {
- binder.bind(item);
+ binder.setBean(item);
binder.bind(nameField, "firstname");
assertEquals("Johannes", nameField.getValue());
@@ -54,7 +54,7 @@ public class BeanBinderTest
@Test
public void beanBound_setValidFieldValue_propertyValueChanged() {
- binder.bind(item);
+ binder.setBean(item);
binder.bind(nameField, "firstname");
nameField.setValue("Henri");
@@ -65,7 +65,7 @@ public class BeanBinderTest
@Test
public void readOnlyPropertyBound_setFieldValue_ignored() {
binder.bind(nameField, "readOnlyProperty");
- binder.bind(item);
+ binder.setBean(item);
String propertyValue = item.getReadOnlyProperty();
nameField.setValue("Foo");
@@ -75,7 +75,7 @@ public class BeanBinderTest
@Test
public void beanBound_setInvalidFieldValue_validationError() {
- binder.bind(item);
+ binder.setBean(item);
binder.bind(nameField, "firstname");
nameField.setValue("H"); // too short
@@ -116,13 +116,13 @@ public class BeanBinderTest
@Test(expected = ClassCastException.class)
public void fieldWithIncompatibleTypeBound_bindBean_throws() {
binder.bind(ageField, "age");
- binder.bind(item);
+ binder.setBean(item);
}
@Test(expected = ClassCastException.class)
public void fieldWithIncompatibleTypeBound_loadBean_throws() {
binder.bind(ageField, "age");
- binder.load(item);
+ binder.readBean(item);
}
@Test(expected = ClassCastException.class)
@@ -130,7 +130,7 @@ public class BeanBinderTest
throws Throwable {
try {
binder.bind(ageField, "age");
- binder.save(item);
+ binder.writeBean(item);
} catch (RuntimeException e) {
throw e.getCause();
}
@@ -140,7 +140,7 @@ public class BeanBinderTest
public void fieldWithConverterBound_bindBean_fieldValueUpdated() {
binder.forField(ageField)
.withConverter(Integer::valueOf, String::valueOf).bind("age");
- binder.bind(item);
+ binder.setBean(item);
assertEquals("32", ageField.getValue());
}
@@ -149,7 +149,7 @@ public class BeanBinderTest
public void fieldWithInvalidConverterBound_bindBean_fieldValueUpdated() {
binder.forField(ageField).withConverter(Float::valueOf, String::valueOf)
.bind("age");
- binder.bind(item);
+ binder.setBean(item);
assertEquals("32", ageField.getValue());
}
@@ -158,7 +158,7 @@ public class BeanBinderTest
public void beanBinderWithBoxedType() {
binder.forField(ageField)
.withConverter(Integer::valueOf, String::valueOf).bind("age");
- binder.bind(item);
+ binder.setBean(item);
ageField.setValue(String.valueOf(20));
assertEquals(20, item.getAge());
diff --git a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java
index d9750b989a..e8007d5f1d 100644
--- a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java
@@ -146,7 +146,7 @@ public class BinderBookOfVaadinTest {
@Test
public void loadingFromBusinessObjects() {
// this test is just to make sure the code snippet in the book compiles
- binder.load(new BookPerson(1969, 50000));
+ binder.readBean(new BookPerson(1969, 50000));
BinderValidationStatus<BookPerson> status = binder.validate();
@@ -160,7 +160,7 @@ public class BinderBookOfVaadinTest {
public void handlingCheckedException() {
// another test just to verify that book examples actually compile
try {
- binder.save(new BookPerson(2000, 50000));
+ binder.writeBean(new BookPerson(2000, 50000));
} catch (ValidationException e) {
Notification.show("Validation error count: "
+ e.getValidationErrors().size());
@@ -265,15 +265,15 @@ public class BinderBookOfVaadinTest {
// Test that the book code works
BookPerson bookPerson = new BookPerson(1972, 4);
- binder.bind(bookPerson);
+ binder.setBean(bookPerson);
Assert.assertEquals(4.0, salaryLevelField.getValue().doubleValue(), 0);
Assert.assertEquals("1,972", yearOfBirthField.getValue());
bookPerson.setSalaryLevel(8);
- binder.load(bookPerson);
+ binder.readBean(bookPerson);
Assert.assertEquals(8.0, salaryLevelField.getValue().doubleValue(), 0);
bookPerson.setYearOfBirth(123);
- binder.load(bookPerson);
+ binder.readBean(bookPerson);
Assert.assertEquals("123", yearOfBirthField.getValue());
yearOfBirthField.setValue("2016");
@@ -293,7 +293,7 @@ public class BinderBookOfVaadinTest {
"Please enter a number")
.bind(BookPerson::getYearOfBirth, BookPerson::setYearOfBirth);
- binder.bind(new BookPerson(1900, 5));
+ binder.setBean(new BookPerson(1900, 5));
yearOfBirthField.setValue("abc");
binder.validate();
Assert.assertEquals("Please&#32;enter&#32;a&#32;number",
@@ -479,24 +479,24 @@ public class BinderBookOfVaadinTest {
BookPerson person = new BookPerson(1900, 5);
person.setEmail("Old Email");
// Load person data to a form
- binder.load(person);
+ binder.readBean(person);
Button saveButton = new Button("Save", event -> {
// Using saveIfValid to avoid the try-catch block that is
// needed if using the regular save method
- if (binder.saveIfValid(person)) {
+ if (binder.writeBeanIfValid(person)) {
// Person is valid and updated
// TODO Store in the database
}
});
emailField.setValue("foo@bar.com");
- Assert.assertTrue(binder.saveIfValid(person));
+ Assert.assertTrue(binder.writeBeanIfValid(person));
// Person updated
Assert.assertEquals("foo@bar.com", person.getEmail());
emailField.setValue("");
- Assert.assertFalse(binder.saveIfValid(person));
+ Assert.assertFalse(binder.writeBeanIfValid(person));
// Person updated because phone and email are both empty
Assert.assertEquals("foo@bar.com", person.getEmail());
}
@@ -530,7 +530,7 @@ public class BinderBookOfVaadinTest {
yearOfBirthField.setValue("1950");
Assert.assertFalse(binder.validate().hasErrors());
BookPerson person = new BookPerson(1500, 12);
- binder.save(person);
+ binder.writeBean(person);
Assert.assertEquals(1950, person.getYearOfBirth());
}
@@ -567,7 +567,7 @@ public class BinderBookOfVaadinTest {
.bind(BookPerson::getYearOfBirth, BookPerson::setYearOfBirth);
BookPerson p = new BookPerson(1500, 12);
- binder.bind(p);
+ binder.setBean(p);
yearOfBirthField.setValue("abc");
Assert.assertTrue(binder.validate().hasErrors());
@@ -578,7 +578,7 @@ public class BinderBookOfVaadinTest {
Assert.assertTrue(binder.validate().isOk());
p.setYearOfBirth(12500);
- binder.load(p);
+ binder.readBean(p);
Assert.assertEquals("12500", yearOfBirthField.getValue());
Assert.assertTrue(binder.validate().isOk());
}
@@ -603,7 +603,7 @@ public class BinderBookOfVaadinTest {
.withValidator(bean -> bean.yearOfBirth == 2000
? Result.error(message2) : Result.ok(bean));
- binder.bind(p);
+ binder.setBean(p);
// first bean validator fails and passes error message to status label
yearOfBirth.setValue("2001");
@@ -672,7 +672,7 @@ public class BinderBookOfVaadinTest {
.withValidator(bean -> bean.yearOfBirth == 2000
? Result.error(message2) : Result.ok(bean));
- binder.bind(p);
+ binder.setBean(p);
// first binding validation fails, no bean level validation is done
yearOfBirth.setValue("2001");
@@ -742,7 +742,7 @@ public class BinderBookOfVaadinTest {
verifyEventIsFired(eventIsFired);
BookPerson person = new BookPerson(2000, 1);
- binder.load(person);
+ binder.readBean(person);
// no changes
Assert.assertFalse(saveButton.isEnabled());
Assert.assertFalse(resetButton.isEnabled());
@@ -755,7 +755,7 @@ public class BinderBookOfVaadinTest {
Assert.assertTrue(resetButton.isEnabled());
Assert.assertTrue(eventIsFired.get());
- binder.saveIfValid(person);
+ binder.writeBeanIfValid(person);
// no changes
Assert.assertFalse(saveButton.isEnabled());
Assert.assertFalse(resetButton.isEnabled());
@@ -800,7 +800,7 @@ public class BinderBookOfVaadinTest {
verifyEventIsFired(eventIsFired);
BookPerson person = new BookPerson(2000, 1);
- binder.bind(person);
+ binder.setBean(person);
// no changes
Assert.assertFalse(saveButton.isEnabled());
Assert.assertFalse(resetButton.isEnabled());
@@ -821,7 +821,7 @@ public class BinderBookOfVaadinTest {
// set valid value
field.setValue("a");
verifyEventIsFired(eventIsFired);
- binder.saveIfValid(person);
+ binder.writeBeanIfValid(person);
// there are no changes.
Assert.assertFalse(saveButton.isEnabled());
Assert.assertFalse(resetButton.isEnabled());
diff --git a/server/src/test/java/com/vaadin/data/BinderComponentTest.java b/server/src/test/java/com/vaadin/data/BinderComponentTest.java
index e91f085f7e..bf3d1a5074 100644
--- a/server/src/test/java/com/vaadin/data/BinderComponentTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderComponentTest.java
@@ -72,7 +72,7 @@ public class BinderComponentTest
field.setValue(initialValue);
Assert.assertEquals("Initial value of field unexpected", initialValue,
field.getValue());
- binder.bind(item);
+ binder.setBean(item);
Assert.assertEquals("Null representation for field failed",
field.getEmptyValue(), field.getValue());
field.setValue(initialValue);
diff --git a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java
index 1ce373bf47..d03f81e873 100644
--- a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java
@@ -138,7 +138,7 @@ public class BinderConverterValidatorTest
.bind(Person::getSalaryDouble, Person::setSalaryDouble);
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
salaryField.setValue("10");
assertEquals(10, person.getSalaryDouble(), 0);
salaryField.setValue("-1"); // Does not pass validator
@@ -205,7 +205,7 @@ public class BinderConverterValidatorTest
public void convertDataToField() {
bindAgeWithValidatorConverterValidator();
binder.getBean().get().setAge(12);
- binder.load(binder.getBean().get());
+ binder.readBean(binder.getBean().get());
assertEquals("12", ageField.getValue());
}
@@ -213,7 +213,7 @@ public class BinderConverterValidatorTest
public void convertNotValidatableDataToField() {
bindAgeWithValidatorConverterValidator();
binder.getBean().get().setAge(-12);
- binder.load(binder.getBean().get());
+ binder.readBean(binder.getBean().get());
assertEquals("-12", ageField.getValue());
}
@@ -244,10 +244,10 @@ public class BinderConverterValidatorTest
}
});
binding.bind(StatusBean::getStatus, StatusBean::setStatus);
- binder.bind(bean);
+ binder.setBean(bean);
bean.setStatus("3");
- binder.load(bean);
+ binder.readBean(bean);
}
@Test
@@ -258,7 +258,7 @@ public class BinderConverterValidatorTest
String msg = "foo";
binder.withValidator(Validator.from(bean -> false, msg));
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
List<ValidationStatus<?>> errors = binder.validate()
.getFieldValidationErrors();
@@ -275,7 +275,7 @@ public class BinderConverterValidatorTest
binder.withValidator(Validator.from(bean -> false, msg));
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
List<ValidationStatus<?>> errors = binder.validate()
.getFieldValidationErrors();
@@ -296,7 +296,7 @@ public class BinderConverterValidatorTest
String msg2 = "bar";
binder.withValidator(Validator.from(bean -> false, msg2));
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
List<ValidationStatus<?>> errors = binder.validate()
.getFieldValidationErrors();
@@ -316,7 +316,7 @@ public class BinderConverterValidatorTest
String msg = "foo";
binder.withValidator(Validator.from(bean -> true, msg));
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
assertFalse(binder.validate().hasErrors());
assertTrue(binder.validate().isOk());
@@ -335,16 +335,16 @@ public class BinderConverterValidatorTest
Person person = new Person();
String firstName = "first name";
person.setFirstName(firstName);
- binder.load(person);
+ binder.readBean(person);
nameField.setValue("");
- assertFalse(binder.saveIfValid(person));
+ assertFalse(binder.writeBeanIfValid(person));
// check that field level-validation failed and bean is not updated
assertEquals(firstName, person.getFirstName());
nameField.setValue("new name");
- assertFalse(binder.saveIfValid(person));
+ assertFalse(binder.writeBeanIfValid(person));
// Bean is updated but reverted
assertEquals(firstName, person.getFirstName());
}
@@ -387,24 +387,24 @@ public class BinderConverterValidatorTest
"Name can't be empty"))
.bind(Person::getFirstName, Person::setFirstName);
assertFalse(binder.hasChanges());
- binder.bind(item);
+ binder.setBean(item);
assertFalse(binder.hasChanges());
nameField.setValue("foo");
assertTrue(binder.hasChanges());
- binder.load(item);
+ binder.readBean(item);
assertFalse(binder.hasChanges());
nameField.setValue("bar");
- binder.saveIfValid(new Person());
+ binder.writeBeanIfValid(new Person());
assertFalse(binder.hasChanges());
nameField.setValue("baz");
- binder.save(new Person());
+ binder.writeBean(new Person());
assertFalse(binder.hasChanges());
nameField.setValue("");
- binder.saveIfValid(new Person());
+ binder.writeBeanIfValid(new Person());
assertTrue(binder.hasChanges());
}
@@ -420,7 +420,7 @@ public class BinderConverterValidatorTest
person.setFirstName(firstName);
nameField.setValue("");
try {
- binder.save(person);
+ binder.writeBean(person);
} finally {
// Bean should not have been updated
Assert.assertEquals(firstName, person.getFirstName());
@@ -438,7 +438,7 @@ public class BinderConverterValidatorTest
Person person = new Person();
nameField.setValue("foo");
try {
- binder.save(person);
+ binder.writeBean(person);
} finally {
// Bean should have been updated for item validation but reverted
Assert.assertNull(person.getFirstName());
@@ -456,7 +456,7 @@ public class BinderConverterValidatorTest
Person person = new Person();
person.setLastName("bar");
nameField.setValue("foo");
- binder.save(person);
+ binder.writeBean(person);
Assert.assertEquals(nameField.getValue(), person.getFirstName());
Assert.assertEquals("bar", person.getLastName());
}
@@ -470,7 +470,7 @@ public class BinderConverterValidatorTest
Person person = new Person();
person.setFirstName("foo");
nameField.setValue("");
- Assert.assertFalse(binder.saveIfValid(person));
+ Assert.assertFalse(binder.writeBeanIfValid(person));
Assert.assertEquals("foo", person.getFirstName());
}
@@ -484,7 +484,7 @@ public class BinderConverterValidatorTest
person.setFirstName("foo");
nameField.setValue("bar");
- Assert.assertTrue(binder.saveIfValid(person));
+ Assert.assertTrue(binder.writeBeanIfValid(person));
Assert.assertEquals("bar", person.getFirstName());
}
@@ -502,7 +502,7 @@ public class BinderConverterValidatorTest
Person person = new Person();
person.setFirstName("foo");
nameField.setValue("");
- Assert.assertFalse(binder.saveIfValid(person));
+ Assert.assertFalse(binder.writeBeanIfValid(person));
Assert.assertEquals("foo", person.getFirstName());
}
@@ -525,7 +525,7 @@ public class BinderConverterValidatorTest
nameField.setValue("null");
- binder.save(person);
+ binder.writeBean(person);
Assert.assertNull(person.getFirstName());
}
@@ -546,7 +546,7 @@ public class BinderConverterValidatorTest
nameField.setValue("");
ageField.setValue("-1");
try {
- binder.save(person);
+ binder.writeBean(person);
Assert.fail();
} catch (ValidationException exception) {
List<ValidationStatus<?>> validationErrors = exception
@@ -572,7 +572,7 @@ public class BinderConverterValidatorTest
? Result.error("error") : Result.ok(bean));
Person person = new Person();
person.setFirstName("");
- binder.bind(person);
+ binder.setBean(person);
// initial value is invalid but no error
Assert.assertNull(nameField.getComponentError());
@@ -585,7 +585,7 @@ public class BinderConverterValidatorTest
// bind to another person to see that error is cleared
person = new Person();
person.setFirstName("");
- binder.bind(person);
+ binder.setBean(person);
// error has been cleared
Assert.assertNull(nameField.getComponentError());
@@ -595,7 +595,7 @@ public class BinderConverterValidatorTest
Assert.assertNotNull(nameField.getComponentError());
// load should also clear error
- binder.load(person);
+ binder.readBean(person);
Assert.assertNull(nameField.getComponentError());
// bind a new field that has invalid value in bean
@@ -621,17 +621,17 @@ public class BinderConverterValidatorTest
Assert.assertEquals("error", statusLabel.getValue());
// reload bean to clear error
- binder.load(person);
+ binder.readBean(person);
Assert.assertEquals("", statusLabel.getValue());
- // unbind() should clear all errors and status label
+ // reset() should clear all errors and status label
nameField.setValue("");
lastNameField.setValue("");
Assert.assertNotNull(nameField.getComponentError());
Assert.assertNotNull(lastNameField.getComponentError());
statusLabel.setComponentError(new UserError("ERROR"));
- binder.unbind();
+ binder.removeBean();
Assert.assertNull(nameField.getComponentError());
Assert.assertNull(lastNameField.getComponentError());
Assert.assertEquals("", statusLabel.getValue());
@@ -659,7 +659,7 @@ public class BinderConverterValidatorTest
nameField.addValueChangeListener(v -> lastNameBinding.validate());
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
Assert.assertNull(nameField.getComponentError());
Assert.assertNull(lastNameField.getComponentError());
@@ -669,7 +669,7 @@ public class BinderConverterValidatorTest
Assert.assertNotNull(nameField.getComponentError());
Assert.assertNotNull(lastNameField.getComponentError());
- binder.bind(person);
+ binder.setBean(person);
Assert.assertNull(nameField.getComponentError());
Assert.assertNull(lastNameField.getComponentError());
@@ -677,14 +677,14 @@ public class BinderConverterValidatorTest
protected void bindName() {
binder.bind(nameField, Person::getFirstName, Person::setFirstName);
- binder.bind(item);
+ binder.setBean(item);
}
protected void bindAgeWithValidatorConverterValidator() {
binder.forField(ageField).withValidator(notEmpty)
.withConverter(stringToInteger).withValidator(notNegative)
.bind(Person::getAge, Person::setAge);
- binder.bind(item);
+ binder.setBean(item);
}
@Test(expected = ValidationException.class)
@@ -700,7 +700,7 @@ public class BinderConverterValidatorTest
Person person = new Person();
ageField.setValue("1");
try {
- binder.save(person);
+ binder.writeBean(person);
} finally {
// Bean should have been updated for item validation but reverted
Assert.assertEquals(0, person.getAge());
diff --git a/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java b/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java
index 318cb4e3d9..f8a4313b09 100644
--- a/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderMultiSelectTest.java
@@ -74,7 +74,7 @@ public class BinderMultiSelectTest
@Test
public void beanBound_bindSelectByShortcut_selectionUpdated() {
item.setEnums(Collections.singleton(TestEnum.ONE));
- binder.bind(item);
+ binder.setBean(item);
binder.bind(select, BeanWithEnums::getEnums, BeanWithEnums::setEnums);
assertEquals(Collections.singleton(TestEnum.ONE),
@@ -84,7 +84,7 @@ public class BinderMultiSelectTest
@Test
public void beanBound_bindSelect_selectionUpdated() {
item.setEnums(Collections.singleton(TestEnum.TWO));
- binder.bind(item);
+ binder.setBean(item);
binder.forField(select).bind(BeanWithEnums::getEnums,
BeanWithEnums::setEnums);
@@ -125,7 +125,7 @@ public class BinderMultiSelectTest
Set<TestEnum> enums = item.getEnums();
- binder.bind(new BeanWithEnums());
+ binder.setBean(new BeanWithEnums());
select.select(TestEnum.ONE);
assertEquals(Collections.singleton(TestEnum.TWO), enums);
@@ -145,7 +145,7 @@ public class BinderMultiSelectTest
public void unbound_changeSelection_beanValueNotUpdated() {
item.setEnums(Collections.singleton(TestEnum.ONE));
bindEnum();
- binder.unbind();
+ binder.removeBean();
select.select(TestEnum.TWO);
@@ -154,7 +154,7 @@ public class BinderMultiSelectTest
@Test
public void withConverter_load_selectUpdated() {
- converterBinder.load(new AtomicReference<>("TWO"));
+ converterBinder.readBean(new AtomicReference<>("TWO"));
assertEquals(Collections.singleton(TestEnum.TWO),
select.getSelectionModel().getSelectedItems());
@@ -166,7 +166,7 @@ public class BinderMultiSelectTest
select.select(TestEnum.TWO);
AtomicReference<String> reference = new AtomicReference<>("");
- converterBinder.saveIfValid(reference);
+ converterBinder.writeBeanIfValid(reference);
assertEquals("ONE,TWO", reference.get());
}
@@ -177,7 +177,7 @@ public class BinderMultiSelectTest
.withValidator(selection -> selection.size() % 2 == 1,
"Must select odd number of items")
.bind(BeanWithEnums::getEnums, BeanWithEnums::setEnums);
- binder.bind(item);
+ binder.setBean(item);
assertFalse(binder.validate().isOk());
@@ -189,6 +189,6 @@ public class BinderMultiSelectTest
protected void bindEnum() {
binder.forField(select).bind(BeanWithEnums::getEnums,
BeanWithEnums::setEnums);
- binder.bind(item);
+ binder.setBean(item);
}
}
diff --git a/server/src/test/java/com/vaadin/data/BinderSingleSelectTest.java b/server/src/test/java/com/vaadin/data/BinderSingleSelectTest.java
index b911692bd0..00a946247d 100644
--- a/server/src/test/java/com/vaadin/data/BinderSingleSelectTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderSingleSelectTest.java
@@ -42,7 +42,7 @@ public class BinderSingleSelectTest
@Test
public void personBound_bindSelectByShortcut_selectionUpdated() {
item.setSex(Sex.FEMALE);
- binder.bind(item);
+ binder.setBean(item);
binder.bind(select, Person::getSex, Person::setSex);
assertSame(Sex.FEMALE, select.getSelectedItem().orElse(null));
@@ -51,7 +51,7 @@ public class BinderSingleSelectTest
@Test
public void personBound_bindSelect_selectionUpdated() {
item.setSex(Sex.MALE);
- binder.bind(item);
+ binder.setBean(item);
binder.forField(select).bind(Person::getSex, Person::setSex);
assertSame(Sex.MALE, select.getSelectedItem().orElse(null));
@@ -95,7 +95,7 @@ public class BinderSingleSelectTest
public void unbound_changeSelection_beanValueNotUpdated() {
item.setSex(Sex.UNKNOWN);
bindSex();
- binder.unbind();
+ binder.removeBean();
select.select(Sex.FEMALE);
@@ -104,6 +104,6 @@ public class BinderSingleSelectTest
protected void bindSex() {
binder.forField(select).bind(Person::getSex, Person::setSex);
- binder.bind(item);
+ binder.setBean(item);
}
}
diff --git a/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java b/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java
index 42550a0862..b394bd8d72 100644
--- a/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java
@@ -60,32 +60,36 @@ public class BinderStatusChangeTest
Assert.assertNull(event.get());
- binder.bind(item);
+ binder.setBean(item);
verifyEvent();
}
@Test
- public void unbindBinder_bound_singleEventWhenBound() {
- binder.bind(item);
+ public void removeBean_bound_singleEventWhenUnBound() {
+ binder.setBean(item);
- unbindBinder_unbound_singleEventWhenBound();
+ binder.addStatusChangeListener(this::statusChanged);
+
+ Assert.assertNull(event.get());
+ binder.removeBean();
+ verifyEvent();
}
@Test
- public void unbindBinder_unbound_singleEventWhenBound() {
+ public void removeBean_unbound_noEventWhenUnBound() {
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.unbind();
- verifyEvent();
+ binder.removeBean();
+ Assert.assertNull(event.get());
}
@Test
public void setValue_bound_singleEventOnSetValue() {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.bind(item);
+ binder.setBean(item);
binder.addStatusChangeListener(this::statusChanged);
@@ -101,7 +105,7 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.bind(item);
+ binder.setBean(item);
binder.addStatusChangeListener(this::statusChanged);
@@ -114,7 +118,7 @@ public class BinderStatusChangeTest
public void setInvalidValue_bound_singleEventOnSetValue() {
binder.forField(nameField).withValidator(name -> false, "")
.bind(Person::getFirstName, Person::setFirstName);
- binder.bind(item);
+ binder.setBean(item);
binder.addStatusChangeListener(this::statusChanged);
@@ -127,7 +131,7 @@ public class BinderStatusChangeTest
public void setInvalidBean_bound_singleEventOnSetValue() {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.bind(item);
+ binder.setBean(item);
binder.withValidator(Validator.from(bean -> false, ""));
@@ -144,7 +148,7 @@ public class BinderStatusChangeTest
Person::setFirstName);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.load(item);
+ binder.readBean(item);
verifyEvent();
}
@@ -157,7 +161,7 @@ public class BinderStatusChangeTest
.bind(Person::getAge, Person::setAge);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.load(item);
+ binder.readBean(item);
verifyEvent();
}
@@ -165,7 +169,7 @@ public class BinderStatusChangeTest
public void load_hasNoBindings_singleEvent() {
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.load(item);
+ binder.readBean(item);
verifyEvent();
}
@@ -173,7 +177,7 @@ public class BinderStatusChangeTest
public void save_hasNoBindings_singleEvent() throws ValidationException {
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.save(item);
+ binder.writeBean(item);
verifyEvent();
}
@@ -181,7 +185,7 @@ public class BinderStatusChangeTest
public void saveIfValid_hasNoBindings_singleEvent() {
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.saveIfValid(item);
+ binder.writeBeanIfValid(item);
verifyEvent();
}
@@ -189,11 +193,11 @@ public class BinderStatusChangeTest
public void save_hasBindings_singleEvent() throws ValidationException {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.save(item);
+ binder.writeBean(item);
verifyEvent();
}
@@ -205,11 +209,11 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.load(item);
+ binder.readBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.save(item);
+ binder.writeBean(item);
verifyEvent();
}
@@ -217,11 +221,11 @@ public class BinderStatusChangeTest
public void saveIfValid_hasBindings_singleEvent() {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.saveIfValid(item);
+ binder.writeBeanIfValid(item);
verifyEvent();
}
@@ -232,11 +236,11 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.load(item);
+ binder.readBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.saveIfValid(item);
+ binder.writeBeanIfValid(item);
verifyEvent();
}
@@ -244,12 +248,12 @@ public class BinderStatusChangeTest
public void saveInvalidValue_hasBindings_singleEvent() {
binder.forField(nameField).withValidator(name -> false, "")
.bind(Person::getFirstName, Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
try {
- binder.save(item);
+ binder.writeBean(item);
} catch (ValidationException ignore) {
}
verifyEvent(true);
@@ -259,11 +263,11 @@ public class BinderStatusChangeTest
public void saveIfValid_invalidValueAndBinderHasBindings_singleEvent() {
binder.forField(nameField).withValidator(name -> false, "")
.bind(Person::getFirstName, Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.saveIfValid(item);
+ binder.writeBeanIfValid(item);
verifyEvent(true);
}
@@ -274,11 +278,11 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.load(item);
+ binder.readBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.saveIfValid(item);
+ binder.writeBeanIfValid(item);
verifyEvent(true);
}
@@ -286,13 +290,13 @@ public class BinderStatusChangeTest
public void saveInvalidBean_hasBindings_singleEvent() {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.withValidator(Validator.from(person -> false, ""));
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
try {
- binder.save(item);
+ binder.writeBean(item);
} catch (ValidationException ignore) {
}
verifyEvent(true);
@@ -302,12 +306,12 @@ public class BinderStatusChangeTest
public void saveIfValid_invalidBeanAndBinderHasBindings_singleEvent() {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.withValidator(Validator.from(person -> false, ""));
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.saveIfValid(item);
+ binder.writeBeanIfValid(item);
verifyEvent(true);
}
@@ -316,12 +320,12 @@ public class BinderStatusChangeTest
throws ValidationException {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.withValidator(Validator.from(person -> true, ""));
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.save(item);
+ binder.writeBean(item);
verifyEvent();
}
@@ -329,12 +333,12 @@ public class BinderStatusChangeTest
public void saveIfValid_validBeanAndBinderHasBindings_singleEvent() {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.load(item);
+ binder.readBean(item);
binder.withValidator(Validator.from(person -> true, ""));
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
- binder.saveIfValid(item);
+ binder.writeBeanIfValid(item);
verifyEvent();
}
@@ -345,7 +349,7 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.bind(item);
+ binder.setBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
@@ -361,7 +365,7 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.bind(item);
+ binder.setBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
@@ -377,7 +381,7 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.bind(item);
+ binder.setBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
@@ -394,7 +398,7 @@ public class BinderStatusChangeTest
binder.forField(ageField)
.withConverter(new StringToIntegerConverter(""))
.bind(Person::getAge, Person::setAge);
- binder.bind(item);
+ binder.setBean(item);
binder.addStatusChangeListener(this::statusChanged);
Assert.assertNull(event.get());
diff --git a/server/src/test/java/com/vaadin/data/BinderTest.java b/server/src/test/java/com/vaadin/data/BinderTest.java
index 9d8e05feb1..6d33ab437b 100644
--- a/server/src/test/java/com/vaadin/data/BinderTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderTest.java
@@ -3,6 +3,7 @@ package com.vaadin.data;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.util.Objects;
@@ -26,9 +27,13 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
item.setAge(32);
}
- @Test(expected = NullPointerException.class)
- public void bindNullBean_throws() {
- binder.bind(null);
+ @Test
+ public void bindNullBean_noBeanPresent() {
+ binder.setBean(item);
+ assertTrue(binder.getBean().isPresent());
+
+ binder.setBean(null);
+ assertFalse(binder.getBean().isPresent());
}
@Test(expected = NullPointerException.class)
@@ -45,7 +50,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
public void fieldBound_bindItem_fieldValueUpdated() {
binder.forField(nameField).bind(Person::getFirstName,
Person::setFirstName);
- binder.bind(item);
+ binder.setBean(item);
assertEquals("Johannes", nameField.getValue());
}
@@ -57,7 +62,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
@Test
public void beanBound_updateFieldValue_beanValueUpdated() {
- binder.bind(item);
+ binder.setBean(item);
binder.bind(nameField, Person::getFirstName, Person::setFirstName);
assertEquals("Johannes", nameField.getValue());
@@ -68,14 +73,14 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
@Test
public void bound_getBean_returnsBoundBean() {
assertFalse(binder.getBean().isPresent());
- binder.bind(item);
+ binder.setBean(item);
assertSame(item, binder.getBean().get());
}
@Test
public void unbound_getBean_returnsNothing() {
- binder.bind(item);
- binder.unbind();
+ binder.setBean(item);
+ binder.removeBean();
assertFalse(binder.getBean().isPresent());
}
@@ -90,7 +95,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
public void unbound_changeFieldValue_beanValueNotUpdated() {
bindName();
nameField.setValue("Henri");
- binder.unbind();
+ binder.removeBean();
nameField.setValue("Aleksi");
assertEquals("Henri", item.getFirstName());
}
@@ -98,7 +103,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
@Test
public void bindNullSetter_valueChangesIgnored() {
binder.bind(nameField, Person::getFirstName, null);
- binder.bind(item);
+ binder.setBean(item);
nameField.setValue("Artur");
assertEquals(item.getFirstName(), "Johannes");
}
@@ -110,7 +115,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
Person p2 = new Person();
p2.setFirstName("Marlon");
- binder.bind(p2);
+ binder.setBean(p2);
assertEquals("Marlon", nameField.getValue());
assertEquals("Leif", item.getFirstName());
assertSame(p2, binder.getBean().get());
@@ -128,7 +133,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
int age = 10;
person.setAge(age);
- binder.save(person);
+ binder.writeBean(person);
Assert.assertEquals(age, person.getAge());
}
@@ -145,7 +150,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
person.setFirstName("foo");
- binder.save(person);
+ binder.writeBean(person);
Assert.assertEquals(fieldValue, person.getFirstName());
}
@@ -158,7 +163,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
String name = "bar";
person.setFirstName(name);
- binder.load(person);
+ binder.readBean(person);
Assert.assertEquals(name, nameField.getValue());
}
@@ -171,14 +176,14 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
String name = "bar";
person.setFirstName(name);
- binder.load(person);
+ binder.readBean(person);
Assert.assertEquals("", nameField.getValue());
}
protected void bindName() {
binder.bind(nameField, Person::getFirstName, Person::setFirstName);
- binder.bind(item);
+ binder.setBean(item);
}
@Test
@@ -193,7 +198,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
// Bind a person with null value and check that null representation is
// used
- binder.bind(namelessPerson);
+ binder.setBean(namelessPerson);
Assert.assertEquals(
"Null value from bean was not converted to explicit null representation",
nullRepresentation, nameField.getValue());
@@ -223,7 +228,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
Person namelessPerson = new Person(null, "Doe", "", 25, Sex.UNKNOWN,
null);
binder.bind(nullTextField, Person::getFirstName, Person::setFirstName);
- binder.bind(namelessPerson);
+ binder.setBean(namelessPerson);
Assert.assertTrue(nullTextField.isEmpty());
Assert.assertEquals(null, namelessPerson.getFirstName());
@@ -250,7 +255,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
Assert.assertFalse("First name in item should not be null",
Objects.isNull(item.getFirstName()));
- binder.bind(item);
+ binder.setBean(item);
Assert.assertEquals("Field value was not set correctly",
item.getFirstName(), nameField.getValue());
@@ -264,7 +269,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
.withConverter(age -> age,
age -> age == null ? customNullConverter : age)
.bind(Person::getSalary, Person::setSalary);
- binder.bind(item);
+ binder.setBean(item);
Assert.assertEquals(customNullConverter.toString(),
ageField.getValue());
@@ -280,7 +285,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
binder.forField(nameField).bind("firstName");
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals("", nameField.getValue());
}
@@ -295,7 +300,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
.bind("firstName");
Person person = new Person();
- binder.bind(person);
+ binder.setBean(person);
Assert.assertEquals(customNullPointerRepresentation,
nameField.getValue());
@@ -308,7 +313,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
.withValidator(new NotNullValidator(""))
.bind(Person::getFirstName, Person::setFirstName);
item.setFirstName(null);
- binder.bind(item);
+ binder.setBean(item);
Assert.assertEquals(nullRepresentation, nameField.getValue());
diff --git a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java
index 25edfaf347..e85132fef3 100644
--- a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java
@@ -220,7 +220,7 @@ public class BinderValidationStatusTest extends
binder.setValidationStatusHandler(r -> {
statusCapture.set(r);
});
- binder.bind(item);
+ binder.setBean(item);
Assert.assertNull(nameField.getComponentError());
nameField.setValue("");
@@ -314,7 +314,7 @@ public class BinderValidationStatusTest extends
binder.setValidationStatusHandler(r -> {
statusCapture.set(r);
});
- binder.bind(item);
+ binder.setBean(item);
Assert.assertNull(nameField.getComponentError());
nameField.setValue("");
diff --git a/server/src/test/java/com/vaadin/data/Jsr303Test.java b/server/src/test/java/com/vaadin/data/Jsr303Test.java
index 876fb534a3..74e97432ba 100644
--- a/server/src/test/java/com/vaadin/data/Jsr303Test.java
+++ b/server/src/test/java/com/vaadin/data/Jsr303Test.java
@@ -92,7 +92,7 @@ public class Jsr303Test {
item.setAge(32);
binder.bind(nameField, "firstname");
- binder.bind(item);
+ binder.setBean(item);
assertEquals(name, nameField.getValue());
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java
index 8393cc4d94..86510f5879 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java
@@ -1030,7 +1030,7 @@ public class CalendarTest extends UI {
initFormFields(scheduleEventFieldLayout, event.getClass());
scheduleEventFieldGroup.setBuffered(true);
scheduleEventFieldGroup.setItemDataSource(item);
- scheduledEventBinder.load(event);
+ scheduledEventBinder.readBean(event);
}
private void setFormDateResolution(Resolution resolution) {
@@ -1064,7 +1064,7 @@ public class CalendarTest extends UI {
throws CommitException, ValidationException {
scheduleEventFieldGroup.commit();
BasicEvent event = getFormCalendarEvent();
- scheduledEventBinder.save(event);
+ scheduledEventBinder.writeBean(event);
if (event.getEnd() == null) {
event.setEnd(event.getStart());
}
@@ -1077,7 +1077,7 @@ public class CalendarTest extends UI {
private void discardCalendarEvent() {
scheduleEventFieldGroup.discard();
- scheduledEventBinder.load(getFormCalendarEvent());
+ scheduledEventBinder.readBean(getFormCalendarEvent());
removeWindow(scheduleEventPopup);
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java
index e732b173fa..9d147eb3b5 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java
@@ -34,7 +34,7 @@ public class SliderValueFromDataSource extends AbstractReindeerTestUI {
b -> Double.valueOf(b.getFloatValue() * 10.0),
(b, doubleValue) -> item.getItemProperty("floatValue")
.setValue((float) (doubleValue / 10.0)));
- binder.bind(bean);
+ binder.setBean(bean);
ProgressBar progressBar = new ProgressBar();
progressBar.setWidth("200px");
diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java
index d1e8fb9acc..1d3a363e6b 100644
--- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java
@@ -971,7 +971,7 @@ public class CalendarTest extends GridLayout implements View {
initFormFields(scheduleEventFieldLayout, event.getClass());
scheduleEventFieldGroup.setBuffered(true);
scheduleEventFieldGroup.setItemDataSource(item);
- scheduledEventBinder.load(event);
+ scheduledEventBinder.readBean(event);
}
private void setFormDateResolution(Resolution resolution) {
@@ -1004,7 +1004,7 @@ public class CalendarTest extends GridLayout implements View {
throws ValidationException, CommitException {
scheduleEventFieldGroup.commit();
BasicEvent event = getFormCalendarEvent();
- scheduledEventBinder.save(event);
+ scheduledEventBinder.writeBean(event);
if (event.getEnd() == null) {
event.setEnd(event.getStart());
}
@@ -1017,7 +1017,7 @@ public class CalendarTest extends GridLayout implements View {
private void discardCalendarEvent() {
scheduleEventFieldGroup.discard();
- scheduledEventBinder.load(getFormCalendarEvent());
+ scheduledEventBinder.readBean(getFormCalendarEvent());
getUI().removeWindow(scheduleEventPopup);
}