Class BeanValidationConfiguration
java.lang.Object
org.apache.wicket.bean.validation.BeanValidationConfiguration
- All Implemented Interfaces:
BeanValidationContext
,IPropertyResolver
Configures bean validation and integrates it with Wicket
- Author:
- igor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(IPropertyResolver resolver) Adds a property resolver to the configuration.void
configure
(Application application) Binds this configuration to the application instancestatic BeanValidationContext
get()
Retrieves the validation context (read only version of the configuration).<T extends Annotation>
ITagModifier<T>getTagModifier
(Class<T> annotationType) Get the registered modifier for the given annotation.jakarta.validation.Validator
boolean
isRequiredConstraint
(jakarta.validation.metadata.ConstraintDescriptor<?> constraint) By defaultNotNull
andNotEmpty
constraints make a component required.<T extends Annotation>
BeanValidationConfigurationregister
(Class<T> annotationType, ITagModifier<T> modifier) Registers a tag modifier for a specific constraint annotation.resolveProperty
(FormComponent<?> component) Resolve the property for a component.void
setValidatorProvider
(Supplier<jakarta.validation.Validator> validatorProvider) Sets the provider used to retrieveValidator
instancesvoid
setViolationTranslator
(IViolationTranslator violationTranslator) Registers a violation translator
-
Constructor Details
-
BeanValidationConfiguration
public BeanValidationConfiguration()
-
-
Method Details
-
register
public <T extends Annotation> BeanValidationConfiguration register(Class<T> annotationType, ITagModifier<T> modifier) Registers a tag modifier for a specific constraint annotation.By default
Size
constraints are automatically mapped tomaxlength
of text inputs, this can be disabled by registering aITagModifier.NO_OP
instead:configuration.register(Size.class, ITagModifier.NO_OP});
- Parameters:
annotationType
- constraint annotation such asSize
modifier
- tag modifier to use- Returns:
this
-
getTagModifier
Get the registered modifier for the given annotation.- Specified by:
getTagModifier
in interfaceBeanValidationContext
- Returns:
- tag modifier or
null
if none - See Also:
-
add
Adds a property resolver to the configuration. Property resolvers registered last are the first to be allowed to resolve the property.- Parameters:
resolver
-- Returns:
this
-
getValidator
- Specified by:
getValidator
in interfaceBeanValidationContext
- Returns:
- validator
-
setValidatorProvider
Sets the provider used to retrieveValidator
instances- Parameters:
validatorProvider
-
-
configure
Binds this configuration to the application instance- Parameters:
application
-
-
getViolationTranslator
- Specified by:
getViolationTranslator
in interfaceBeanValidationContext
- Returns:
- registered violation translator
-
setViolationTranslator
Registers a violation translator- Parameters:
violationTranslator
- A violation translator that will convertConstraintViolation
s into Wicket'sValidationError
s
-
get
Retrieves the validation context (read only version of the configuration). This is how components retrieve the configuration.- Returns:
- validation context
-
resolveProperty
Description copied from interface:BeanValidationContext
Resolve the property for a component.- Specified by:
resolveProperty
in interfaceBeanValidationContext
- Specified by:
resolveProperty
in interfaceIPropertyResolver
- Parameters:
component
- component
-
isRequiredConstraint
By defaultNotNull
andNotEmpty
constraints make a component required.- Specified by:
isRequiredConstraint
in interfaceBeanValidationContext
- Parameters:
constraint
- constraint- Returns:
true
if required
-