Package com.vaadin.flow.data.binder
Class BeanValidationBinder<BEAN>
java.lang.Object
com.vaadin.flow.data.binder.Binder<BEAN>
com.vaadin.flow.data.binder.BeanValidationBinder<BEAN>
- Type Parameters:
BEAN
- the bean type
- All Implemented Interfaces:
Serializable
Binder that uses reflection based on the provided bean type to resolve bean
properties. The Binder automatically adds BeanValidator which validates beans
using JSR-303 specification. It assumes that JSR-303 bean validation
implementation is present on the classpath.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.data.binder.Binder
Binder.Binding<BEAN,
TARGET>, Binder.BindingBuilder<BEAN, TARGET>, Binder.BindingBuilderImpl<BEAN, FIELDVALUE, TARGET>, Binder.BindingImpl<BEAN, FIELDVALUE, TARGET> -
Constructor Summary
ConstructorDescriptionBeanValidationBinder
(Class<BEAN> beanType) Creates a new binder that uses reflection based on the provided bean type to resolve bean properties.BeanValidationBinder
(Class<BEAN> beanType, boolean scanNestedDefinitions) Creates a new binder that uses reflection based on the provided bean type to resolve bean properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected Binder.BindingBuilder<BEAN,
?> configureBinding
(Binder.BindingBuilder<BEAN, ?> binding, PropertyDefinition<BEAN, ?> definition) Configures thebinding
with the property definitiondefinition
before it's being bound.Gets field required indicator configuration logic.void
setRequiredConfigurator
(RequiredFieldConfigurator configurator) Sets a logic which allows to configure require indicator viaHasValue.setRequiredIndicatorVisible(boolean)
based on property descriptor.Methods inherited from class com.vaadin.flow.data.binder.Binder
addListener, addStatusChangeListener, addValueChangeListener, bind, bind, bindInstanceFields, bindReadOnly, bindReadOnly, clearError, createBinding, doCreateBinding, forField, forMemberField, getBean, getBeanState, getBinding, getBindingExceptionHandler, getBindings, getConverterFactory, getFields, getStatusLabel, getValidationErrorHandler, getValidationStatusHandler, handleBinderValidationStatus, handleError, handleFieldValueChange, handleValidationStatus, hasChanges, isFieldsValidationStatusChangeListenerEnabled, isValid, isValidatorsDisabled, readBean, refreshFields, removeBean, removeBinding, removeBinding, removeBinding, removeBindingInternal, restoreBeanState, setBean, setBindingExceptionHandler, setFieldsValidationStatusChangeListenerEnabled, setReadOnly, setStatusLabel, setValidationErrorHandler, setValidationStatusHandler, setValidatorsDisabled, validate, validate, withPropertySet, withValidator, withValidator, withValidator, writeBean, writeBeanAsDraft, writeBeanAsDraft, writeBeanIfValid
-
Constructor Details
-
BeanValidationBinder
Creates a new binder that uses reflection based on the provided bean type to resolve bean properties. It assumes that JSR-303 bean validation implementation is present on the classpath. If there is no such implementation available thenBinder
class should be used instead (this constructor will throw an exception). OtherwiseBeanValidator
is added to each binding that is defined using a property name.- Parameters:
beanType
- the bean type to use, notnull
-
BeanValidationBinder
Creates a new binder that uses reflection based on the provided bean type to resolve bean properties. It assumes that JSR-303 bean validation implementation is present on the classpath. If there is no such implementation available thenBinder
class should be used instead (this constructor will throw an exception). OtherwiseBeanValidator
is added to each binding that is defined using a property name.- Parameters:
beanType
- the bean type to use, notnull
scanNestedDefinitions
- iftrue
, scan for nested property definitions as well
-
-
Method Details
-
setRequiredConfigurator
Sets a logic which allows to configure require indicator viaHasValue.setRequiredIndicatorVisible(boolean)
based on property descriptor.Required indicator configuration will not be used at all if
configurator
is null.By default the
RequiredFieldConfigurator.DEFAULT
configurator is used.- Parameters:
configurator
- required indicator configurator, may benull
-
getRequiredConfigurator
Gets field required indicator configuration logic.- Returns:
- required indicator configurator, may be
null
- See Also:
-
configureBinding
protected Binder.BindingBuilder<BEAN,?> configureBinding(Binder.BindingBuilder<BEAN, ?> binding, PropertyDefinition<BEAN, ?> definition) Description copied from class:Binder
Configures thebinding
with the property definitiondefinition
before it's being bound.- Overrides:
configureBinding
in classBinder<BEAN>
- Parameters:
binding
- a binding to configuredefinition
- a property definition information- Returns:
- the new configured binding
-