Class CollaborationBinder.CollaborationBindingBuilderImpl<BEAN,FIELDVALUE,TARGET>

java.lang.Object
com.vaadin.flow.data.binder.Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
com.vaadin.collaborationengine.CollaborationBinder.CollaborationBindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
All Implemented Interfaces:
Binder.BindingBuilder<BEAN,TARGET>, Serializable
Enclosing class:
CollaborationBinder<BEAN>

protected static class CollaborationBinder.CollaborationBindingBuilderImpl<BEAN,FIELDVALUE,TARGET> extends Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
See Also:
  • Constructor Details

  • Method Details

    • bind

      public Binder.Binding<BEAN,TARGET> bind(ValueProvider<BEAN,TARGET> getter, Setter<BEAN,TARGET> setter)
      Description copied from interface: Binder.BindingBuilder
      Completes 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's ValidationStatusChangeEvents 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).

      Specified by:
      bind in interface Binder.BindingBuilder<BEAN,FIELDVALUE>
      Overrides:
      bind in class Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
      Parameters:
      getter - the function to get the value of the property to the field, not null
      setter - the function to write the field value to the property or null if read-only
      Returns:
      the newly created binding
    • bind

      public Binder.Binding<BEAN,TARGET> bind(String propertyName)
      Description copied from interface: Binder.BindingBuilder
      Completes this binding by connecting the field to the property with the given name. The getter and setter of the property are looked up using a PropertySet.

      For a Binder created using the 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. 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:
      bind in interface Binder.BindingBuilder<BEAN,FIELDVALUE>
      Overrides:
      bind in class Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
      Parameters:
      propertyName - the name of the property to bind, not null
      Returns:
      the newly created binding
      See Also:
    • getBinder

      protected CollaborationBinder<BEAN> getBinder()
      Description copied from class: Binder.BindingBuilderImpl
      Returns the Binder connected to this Binding instance.
      Overrides:
      getBinder in class Binder.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.BindingBuilderImpl
      Implements 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.

      Overrides:
      withConverter in class Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET>
      Type Parameters:
      NEWTARGET - the type to convert to
      Parameters:
      converter - the converter to use, not null
      resetNullRepresentation - if true then default null representation will be deactivated (if not yet), otherwise it won't be removed
      Returns:
      a new binding with the appropriate type
      See Also:
    • withNullRepresentation

      public Binder.BindingBuilder<BEAN,TARGET> withNullRepresentation(TARGET nullRepresentation)
      Description copied from interface: Binder.BindingBuilder
      Maps binding value null to given null representation and back to null when converting back to model value.
      Parameters:
      nullRepresentation - the value to use instead of null
      Returns:
      a new binding with null representation handling.