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
ConstructorsConstructorDescriptionBeanValidationBinder(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 thebindingwith the property definitiondefinitionbefore it's being bound.Gets field required indicator configuration logic.voidsetRequiredConfigurator(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, getChangedBindings, getConverterFactory, getFields, getStatusLabel, getValidationErrorHandler, getValidationStatusHandler, handleBinderValidationStatus, handleError, handleFieldValueChange, handleValidationStatus, hasChanges, hasChanges, isChangeDetectionEnabled, isDefaultValidatorsEnabled, isFieldsValidationStatusChangeListenerEnabled, isValid, isValidatorsDisabled, readBean, readRecord, refreshFields, removeBean, removeBinding, removeBinding, removeBinding, removeBindingInternal, restoreBeanState, setBean, setBindingExceptionHandler, setChangeDetectionEnabled, setDefaultValidatorsEnabled, setFieldsValidationStatusChangeListenerEnabled, setReadOnly, setStatusLabel, setValidationErrorHandler, setValidationStatusHandler, setValidatorsDisabled, validate, validate, withPropertySet, withValidator, withValidator, withValidator, writeBean, writeBean, writeBeanAsDraft, writeBeanAsDraft, writeBeanIfValid, writeChangedBindingsToBean, writeRecord
-
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 thenBinderclass should be used instead (this constructor will throw an exception). OtherwiseBeanValidatoris 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 thenBinderclass should be used instead (this constructor will throw an exception). OtherwiseBeanValidatoris added to each binding that is defined using a property name.- Parameters:
beanType- the bean type to use, notnullscanNestedDefinitions- 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
configuratoris null.By default the
RequiredFieldConfigurator.DEFAULTconfigurator 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:BinderConfigures thebindingwith the property definitiondefinitionbefore it's being bound.- Overrides:
configureBindingin classBinder<BEAN>- Parameters:
binding- a binding to configuredefinition- a property definition information- Returns:
- the new configured binding
-