Class CollaborationBinder.CollaborationBindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
- All Implemented Interfaces:
Binder.BindingBuilder<BEAN,,TARGET> Serializable
- Enclosing class:
- CollaborationBinder<BEAN>
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCollaborationBindingBuilderImpl(CollaborationBinder<BEAN> binder, HasValue<?, FIELDVALUE> field, Converter<FIELDVALUE, TARGET> converterValidatorChain, BindingValidationStatusHandler statusHandler) -
Method Summary
Modifier and TypeMethodDescriptionCompletes this binding using the given getter and setter functions representing a backing bean property.Completes this binding by connecting the field to the property with the given name.protected CollaborationBinder<BEAN>Returns theBinderconnected to thisBindinginstance.protected <NEWTARGET>
Binder.BindingBuilder<BEAN,NEWTARGET> withConverter(Converter<TARGET, NEWTARGET> converter, boolean resetNullRepresentation) ImplementsBinder.BindingBuilderImpl.withConverter(Converter)method with additional possibility to disable (reset) default null representation converter.withNullRepresentation(TARGET nullRepresentation) Maps binding valuenullto given null representation and back tonullwhen converting back to model value.Methods inherited from class com.vaadin.flow.data.binder.Binder.BindingBuilderImpl
asRequired, asRequired, bindReadOnly, bindReadOnly, checkUnbound, getField, withConverter, withDefaultValidator, withEqualityPredicate, withValidationStatusHandler, withValidatorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.data.binder.Binder.BindingBuilder
asRequired, asRequired, withConverter, withConverter, withStatusLabel, withValidator, withValidator, withValidator, withValidator
-
Constructor Details
-
CollaborationBindingBuilderImpl
protected CollaborationBindingBuilderImpl(CollaborationBinder<BEAN> binder, HasValue<?, FIELDVALUE> field, Converter<FIELDVALUE, TARGET> converterValidatorChain, BindingValidationStatusHandler statusHandler)
-
-
Method Details
-
bind
public Binder.Binding<BEAN,TARGET> bind(ValueProvider<BEAN, TARGET> getter, Setter<BEAN, TARGET> setter) Description copied from interface:Binder.BindingBuilderCompletes this binding using the given getter and setter functions representing a backing bean property. The functions are used to update the field value from the property and to store the field value to the property, respectively.When a bean is bound with
Binder.setBean(Object), 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 read-only.If the Binder is already bound to some bean, the newly bound field is associated with the corresponding bean property as described above.
If the bound field implements
HasValidator, then the binding instance returned by this method will subscribe for field'sValidationStatusChangeEvents and willvalidateitself upon receiving them.The getter and setter can be arbitrary functions, for instance implementing user-defined conversion or validation. However, in the most basic use case you can simply pass a pair of method references to this method as follows:
class Person { public String getName() { ... } public void setName(String name) { ... } } TextField nameField = new TextField(); binder.forField(nameField).bind(Person::getName, Person::setName);Note: when a
nullsetter is given the field will be marked as readonly by invokingHasValue.setReadOnly(boolean).- Specified by:
bindin interfaceBinder.BindingBuilder<BEAN,FIELDVALUE> - Overrides:
bindin classBinder.BindingBuilderImpl<BEAN,FIELDVALUE, TARGET> - Parameters:
getter- the function to get the value of the property to the field, not nullsetter- the function to write the field value to the property or null if read-only- Returns:
- the newly created binding
-
bind
Description copied from interface:Binder.BindingBuilderCompletes this binding by connecting the field to the property with the given name. The getter and setter of the property are looked up using aPropertySet.For a
Bindercreated using theBinder(Class)constructor, introspection will be used to find a Java Bean property. If a JSR-303 bean validation implementation is present on the classpath, aBeanValidatoris also added to the binding.The property must have an accessible getter method. It need not have an accessible setter; in that case the property value is never updated and the binding is said to be read-only. Nested property, when supported, can be referenced using the bean path, starting from the root class, for example 'address.streetName'. All intermediate getters must exist (e.g.
getAddress()), and should never return null, otherwise binding will fail.Note: when the binding is read-only the field will be marked as readonly by invoking
HasValue.setReadOnly(boolean).- Specified by:
bindin interfaceBinder.BindingBuilder<BEAN,FIELDVALUE> - Overrides:
bindin classBinder.BindingBuilderImpl<BEAN,FIELDVALUE, TARGET> - Parameters:
propertyName- the name of the property to bind, not null- Returns:
- the newly created binding
- See Also:
-
getBinder
Description copied from class:Binder.BindingBuilderImplReturns theBinderconnected to thisBindinginstance.- Overrides:
getBinderin classBinder.BindingBuilderImpl<BEAN,FIELDVALUE, TARGET> - Returns:
- the binder
-
withConverter
protected <NEWTARGET> Binder.BindingBuilder<BEAN,NEWTARGET> withConverter(Converter<TARGET, NEWTARGET> converter, boolean resetNullRepresentation) Description copied from class:Binder.BindingBuilderImplImplementsBinder.BindingBuilderImpl.withConverter(Converter)method with additional possibility to disable (reset) default null representation converter.The method
Binder.BindingBuilderImpl.withConverter(Converter)calls this method withtrueprovided as the second argument value.- Overrides:
withConverterin classBinder.BindingBuilderImpl<BEAN,FIELDVALUE, TARGET> - Type Parameters:
NEWTARGET- the type to convert to- Parameters:
converter- the converter to use, not nullresetNullRepresentation- iftruethen default null representation will be deactivated (if not yet), otherwise it won't be removed- Returns:
- this BindingBuilder configured with the appropriate type
- See Also:
-
withNullRepresentation
Description copied from interface:Binder.BindingBuilderMaps binding valuenullto given null representation and back tonullwhen converting back to model value.- Parameters:
nullRepresentation- the value to use instead ofnull- Returns:
- this BindingBuilder with null representation handling.
-