Package com.vaadin.flow.data.binder
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 set
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
Binder.BindingImpl
public static interface Binder.Binding<BEAN,TARGET> extends Serializable
Represents the binding between a field and a data property.- See Also:
Binder.forField(HasValue)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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.BindingValidationStatusHandlergetValidationStatusHandler()Gets the validation status handler for this Binding.booleanisAsRequiredEnabled()Returns whether asRequired validator is currently enabled or not.booleanisConvertBackToPresentation()Returns whether the value is converted back to the presentation in the field when a converter is used in binding.booleanisReadOnly()Gets the current read-only status for this Binding.booleanisValidatorsDisabled()Returns if validators are currently disabled or not.voidread(BEAN bean)Reads the value from given item and stores it to the bound field.voidsetAsRequiredEnabled(boolean asRequiredEnabled)Enable or disable asRequired validator.voidsetConvertBackToPresentation(boolean convertBackToPresentation)Define whether the value should be converted back to the presentation in the field when a converter is used in binding.voidsetReadOnly(boolean readOnly)Sets the read-only status on for this Binding.voidsetValidatorsDisabled(boolean validatorsDisabled)Define whether validators are disabled or enabled for this specific binding.voidunbind()Unbinds the binding from its respectiveBinder.default BindingValidationStatus<TARGET>validate()Validates the field value and returns aValidationStatusinstance representing the outcome of the validation.BindingValidationStatus<TARGET>validate(boolean fireEvent)Validates the field value and returns aValidationStatusinstance 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 aValidationStatusinstance representing the outcome of the validation. This method is a short-hand for callingvalidate(boolean)withfireEventtrue.- 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 aValidationStatusinstance representing the outcome of the validation.- Parameters:
fireEvent-trueto fire status event;falseto not- Returns:
- the validation result.
- See Also:
validate()
-
getValidationStatusHandler
BindingValidationStatusHandler getValidationStatusHandler()
Gets the validation status handler for this Binding.- Returns:
- the validation status handler for this binding
-
unbind
void unbind()
Unbinds the binding from its respectiveBinder. Removes anyValueChangeListenerRegistrationfrom associatedHasValue.
-
read
void read(BEAN bean)
Reads the value from given item and stores it to the bound field.- Parameters:
bean- the bean to read from
-
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-trueto set binding read-only;falseto enable writes- Throws:
IllegalStateException- if trying to make binding read-write and the setter isnull
-
isReadOnly
boolean isReadOnly()
Gets the current read-only status for this Binding.- Returns:
trueif read-only;falseif not- See Also:
setReadOnly(boolean)
-
getGetter
ValueProvider<BEAN,TARGET> getGetter()
Gets the getter associated with this Binding.- Returns:
- the getter
-
getSetter
Setter<BEAN,TARGET> getSetter()
Gets the setter associated with this Binding.- Returns:
- the setter
-
setAsRequiredEnabled
void setAsRequiredEnabled(boolean asRequiredEnabled)
Enable or disable asRequired validator. The validator is enabled by default.- Parameters:
asRequiredEnabled-falseif asRequired validator should be disabled,trueotherwise (default)- See Also:
Binder.BindingBuilder.asRequired(String),Binder.BindingBuilder.asRequired(ErrorMessageProvider)
-
isAsRequiredEnabled
boolean isAsRequiredEnabled()
Returns whether asRequired validator is currently enabled or not.- Returns:
falseif asRequired validator is disabledtrueotherwise (default)- 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 value.
-
isValidatorsDisabled
boolean isValidatorsDisabled()
Returns if validators are currently disabled or not.- Returns:
- A boolean value.
-
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.As of version 6.0, when a converter is used on a binding and the user input value is modified by the converter, the value from the converter is applied back to the input. It is possible to control this behavior with this API.
- Parameters:
convertBackToPresentation- A boolean value- See Also:
Binder.BindingBuilder.withConverter(Converter),Binder.BindingBuilder.withConverter(SerializableFunction, SerializableFunction),Binder.BindingBuilder.withConverter(SerializableFunction, SerializableFunction, String)
-
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
-
-