com.vaadin.data.
Interface Binder.Binding<BEAN,TARGET>
-
Type Parameters:
BEAN
- the bean typeTARGET
- the target data type of the binding, matches the field type unless a converter has been setAll Superinterfaces:
All Known Implementing Classes:
public static interface Binder.Binding<BEAN,TARGET> extends Serializable
Represents the binding between a field and a data property.
See Also:
-
-
Method Summary
All Methods Modifier and Type Method Description SerializableBiPredicate<TARGET,TARGET>
getEqualityPredicate()
Used in comparison of the current value of a field with its initial value.
HasValue<?>
getField()
Gets the field the binding uses.
ValueProvider<BEAN,TARGET>
getGetter()
Gets the getter associated with this Binding.
Setter<BEAN,TARGET>
getSetter()
Gets the setter associated with this Binding.
BindingValidationStatusHandler
getValidationStatusHandler()
Gets the validation status handler for this Binding.
boolean
hasChanges()
Checks whether the field that the binding uses has uncommitted changes.
boolean
isAsRequiredEnabled()
Returns whether asRequired validator is currently enabled or not.
boolean
isConvertBackToPresentation()
Returns whether the value is converted back to the presentation in the field when a converter is used in binding.
boolean
isReadOnly()
Gets the current read-only status for this Binding.
boolean
isValidatorsDisabled()
Returns if validators are currently disabled or not
void
read(BEAN bean)
Reads the value from given item and stores it to the bound field.
void
setAsRequiredEnabled(boolean asRequiredEnabled)
Enable or disable asRequired validator.
void
setConvertBackToPresentation(boolean convertBackToPresentation)
Define whether the value should be converted back to the presentation in the field when a converter is used in binding.
void
setReadOnly(boolean readOnly)
Sets the read-only status on for this Binding.
void
setValidatorsDisabled(boolean validatorsDisabled)
Define whether validators are disabled or enabled for this specific binding.
void
unbind()
Unbinds the binding from its respective
Binder
Removes anyValueChangeListener
Registration
from associatedHasValue
.default BindingValidationStatus<TARGET>
validate()
Validates the field value and returns a
ValidationStatus
instance representing the outcome of the validation.BindingValidationStatus<TARGET>
validate(boolean fireEvent)
Validates the field value and returns a
ValidationStatus
instance representing the outcome of the validation.
-
-
-
Method Detail
-
getField
HasValue<?> getField()
Gets the field the binding uses.
Returns:
the field for the binding
-
validate
default BindingValidationStatus<TARGET> validate()
Validates the field value and returns a
ValidationStatus
instance representing the outcome of the validation. This method is a short-hand for callingvalidate(boolean)
withfireEvent
true
.Returns:
the validation result.
See Also:
validate(boolean)
,Binder.validate()
,Validator.apply(Object, ValueContext)
-
validate
BindingValidationStatus<TARGET> validate(boolean fireEvent)
Validates the field value and returns a
ValidationStatus
instance representing the outcome of the validation. Note: Calling this method will not trigger the value update in the bean automatically. This method will attempt to temporarily apply all current changes to the bean and run full bean validation for it. The changes are reverted after bean validation.Parameters:
fireEvent
-true
to fire status event;false
to notReturns:
the validation result.
Since:
8.2
See Also:
-
getValidationStatusHandler
BindingValidationStatusHandler getValidationStatusHandler()
Gets the validation status handler for this Binding.
Returns:
the validation status handler for this binding
Since:
8.2
-
unbind
void unbind()
Unbinds the binding from its respective
Binder
Removes anyValueChangeListener
Registration
from associatedHasValue
.Since:
8.2
-
read
void read(BEAN bean)
Reads the value from given item and stores it to the bound field.
Parameters:
bean
- the bean to read fromSince:
8.2
-
setReadOnly
void setReadOnly(boolean readOnly)
Sets the read-only status on for this Binding. Setting a Binding read-only will mark the field read-only and not write any values from the fields to the bean.
This helper method is the preferred way to control the read-only state of the bound field.
Parameters:
readOnly
-true
to set binding read-only;false
to enable writesThrows:
IllegalStateException
- if trying to make binding read-write and the setter isnull
Since:
8.4
-
isReadOnly
boolean isReadOnly()
Gets the current read-only status for this Binding.
Returns:
true
if read-only;false
if notSince:
8.4
See Also:
-
getGetter
ValueProvider<BEAN,TARGET> getGetter()
Gets the getter associated with this Binding.
Returns:
the getter
Since:
8.4
-
getSetter
Setter<BEAN,TARGET> getSetter()
Gets the setter associated with this Binding.
Returns:
the setter
Since:
8.4
-
setAsRequiredEnabled
void setAsRequiredEnabled(boolean asRequiredEnabled)
Enable or disable asRequired validator. The validator is enabled by default.
Parameters:
asRequiredEnabled
-false
if asRequired validator should be disabled,true
otherwise (default)Since:
8.10
See Also:
Binder.BindingBuilder.asRequired(String)
,Binder.BindingBuilder.asRequired(ErrorMessageProvider)
-
isAsRequiredEnabled
boolean isAsRequiredEnabled()
Returns whether asRequired validator is currently enabled or not.
Returns:
false
if asRequired validator is disabledtrue
otherwise (default)Since:
8.10
See Also:
Binder.BindingBuilder.asRequired(String)
,Binder.BindingBuilder.asRequired(ErrorMessageProvider)
-
setValidatorsDisabled
void setValidatorsDisabled(boolean validatorsDisabled)
Define whether validators are disabled or enabled for this specific binding.
Parameters:
validatorsDisabled
- A boolean valueSince:
8.11
-
isValidatorsDisabled
boolean isValidatorsDisabled()
Returns if validators are currently disabled or not
Returns:
A boolean value
Since:
8.11
-
setConvertBackToPresentation
void setConvertBackToPresentation(boolean convertBackToPresentation)
Define whether the value should be converted back to the presentation in the field when a converter is used in binding.
Parameters:
convertBackToPresentation
- A boolean valueSince:
8.13
-
isConvertBackToPresentation
boolean isConvertBackToPresentation()
Returns whether the value is converted back to the presentation in the field when a converter is used in binding.
Returns:
A boolean value
Since:
8.13
-
hasChanges
boolean hasChanges()
Checks whether the field that the binding uses has uncommitted changes.
Returns:
true
if the field the binding uses has uncommitted changes, otherwisefalse
.Throws:
IllegalStateException
- if the binding is no longer attached to a Binder.
-
getEqualityPredicate
SerializableBiPredicate<TARGET,TARGET> getEqualityPredicate()
Used in comparison of the current value of a field with its initial value.
Once set, the value of the field that binding uses will be compared with the initial value for hasChanged.
Returns:
the predicate to use for equality comparison
-
-