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 typeAll Implemented Interfaces:
public class BeanValidationBinder<BEAN> extends Binder<BEAN>
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
Constructors Constructor Description BeanValidationBinder(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
All Methods Modifier and Type Method Description protected Binder.BindingBuilder<BEAN,?>
configureBinding(Binder.BindingBuilder<BEAN,?> binding, PropertyDefinition<BEAN,?> definition)
Configures the
binding
with the property definitiondefinition
before it's being bound.RequiredFieldConfigurator
getRequiredConfigurator()
Gets field required indicator configuration logic.
void
setRequiredConfigurator(RequiredFieldConfigurator configurator)
Sets a logic which allows to configure require indicator via
HasValue.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 Detail
-
BeanValidationBinder
public BeanValidationBinder(Class<BEAN> beanType)
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 then
Binder
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
public BeanValidationBinder(Class<BEAN> beanType, boolean scanNestedDefinitions)
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 then
Binder
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 Detail
-
setRequiredConfigurator
public void setRequiredConfigurator(RequiredFieldConfigurator configurator)
Sets a logic which allows to configure require indicator via
HasValue.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
public RequiredFieldConfigurator 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 the
binding
with the property definitiondefinition
before it's being bound.Overrides:
configureBinding
in classBinder<BEAN>
Parameters:
binding
- a binding to configuredefinition
- a property definition informationReturns:
the new configured binding
-
-