protected static class CollaborationBinder.CollaborationBindingBuilderImpl<BEAN,FIELDVALUE,TARGET> extends Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
Modifier | Constructor and Description |
---|---|
protected |
CollaborationBindingBuilderImpl(CollaborationBinder<BEAN> binder,
HasValue<?,FIELDVALUE> field,
Converter<FIELDVALUE,TARGET> converterValidatorChain,
BindingValidationStatusHandler statusHandler) |
Modifier and Type | Method and Description |
---|---|
Binder.Binding<BEAN,TARGET> |
bind(String propertyName)
Completes this binding by connecting the field to the property with
the given name.
|
Binder.Binding<BEAN,TARGET> |
bind(ValueProvider<BEAN,TARGET> getter,
Setter<BEAN,TARGET> setter)
Completes this binding using the given getter and setter functions
representing a backing bean property.
|
protected CollaborationBinder<BEAN> |
getBinder()
Returns the
Binder connected to this Binding
instance. |
protected <NEWTARGET> |
withConverter(Converter<TARGET,NEWTARGET> converter,
boolean resetNullRepresentation)
Implements
Binder.BindingBuilderImpl.withConverter(Converter) method with additional
possibility to disable (reset) default null representation converter. |
Binder.BindingBuilder<BEAN,TARGET> |
withNullRepresentation(TARGET nullRepresentation)
Maps binding value
null to given null representation and back
to null when converting back to model value. |
asRequired, asRequired, bindReadOnly, bindReadOnly, checkUnbound, getField, withConverter, withValidationStatusHandler, withValidator
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asRequired, asRequired, withConverter, withConverter, withStatusLabel, withValidator, withValidator, withValidator, withValidator
protected CollaborationBindingBuilderImpl(CollaborationBinder<BEAN> binder, HasValue<?,FIELDVALUE> field, Converter<FIELDVALUE,TARGET> converterValidatorChain, BindingValidationStatusHandler statusHandler)
public Binder.Binding<BEAN,TARGET> bind(ValueProvider<BEAN,TARGET> getter, Setter<BEAN,TARGET> setter)
Binder.BindingBuilder
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's
ValidationStatusChangeEvent
s and will validate
itself
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 null
setter is given the field
will be marked as readonly by invoking HasValue.setReadOnly(boolean)
.
bind
in interface Binder.BindingBuilder<BEAN,TARGET>
bind
in class Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
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-onlypublic Binder.Binding<BEAN,TARGET> bind(String propertyName)
Binder.BindingBuilder
PropertySet
.
For a Binder
created using the
Binder.Binder(Class)
constructor, introspection will be used
to find a Java Bean property. If a JSR-303 bean validation
implementation is present on the classpath, a BeanValidator
is 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.
Note: when the binding is read-only the field
will be marked as readonly by invoking HasValue.setReadOnly(boolean)
.
bind
in interface Binder.BindingBuilder<BEAN,TARGET>
bind
in class Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
propertyName
- the name of the property to bind, not nullBinder.BindingBuilder.bind(ValueProvider, Setter)
protected CollaborationBinder<BEAN> getBinder()
Binder.BindingBuilderImpl
Binder
connected to this Binding
instance.getBinder
in class Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
protected <NEWTARGET> Binder.BindingBuilder<BEAN,NEWTARGET> withConverter(Converter<TARGET,NEWTARGET> converter, boolean resetNullRepresentation)
Binder.BindingBuilderImpl
Binder.BindingBuilderImpl.withConverter(Converter)
method with additional
possibility to disable (reset) default null representation converter.
The method Binder.BindingBuilderImpl.withConverter(Converter)
calls this method with
true
provided as the second argument value.
withConverter
in class Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
NEWTARGET
- the type to convert toconverter
- the converter to use, not nullresetNullRepresentation
- if true
then default null representation will be
deactivated (if not yet), otherwise it won't be removedBinder.BindingBuilderImpl.withConverter(Converter)
public Binder.BindingBuilder<BEAN,TARGET> withNullRepresentation(TARGET nullRepresentation)
Binder.BindingBuilder
null
to given null representation and back
to null
when converting back to model value.nullRepresentation
- the value to use instead of null
Copyright © 2022. All rights reserved.