Class PropertyValidator<T>
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.bean.validation.PropertyValidator<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
Serializable,org.apache.wicket.IComponentAwareEventSink,org.apache.wicket.markup.html.IComponentAwareHeaderContributor,org.apache.wicket.util.io.IClusterable,org.apache.wicket.validation.INullAcceptingValidator<T>,org.apache.wicket.validation.IValidator<T>
public class PropertyValidator<T> extends org.apache.wicket.behavior.Behavior implements org.apache.wicket.validation.INullAcceptingValidator<T>
Validator that delegates to the bean validation framework. The integration has to be first configured usingBeanValidationConfiguration.The validator must be provided a
Property, unless one can be resolved from the component implicitly. By default the configuration contains theDefaultPropertyResolversoPropertyModels are supported out of the box - when attached to a component with a property model the property does not need to be specified explicitly.The validator will set the required flag on the form component it is attached to based on the presence of the @NotNull annotation, see
BeanValidationContext.isRequiredConstraint(ConstraintDescriptor)for details. Notice, the required flag will only be set totrue, components with the required flag already set totruewill not have the flag set tofalseby this validator.The validator will allow
ITagModifiers registered onBeanValidationContextto mutate the markup tag of the component it is attached to, e.g. add amaxlengthattribute.The validator specifies default error messages in the
PropertyValidator.propertiesfile. These values can be overridden in the application subclass' property files globally or in the page or panel properties locally. See this file for the default messages supported.- Author:
- igor
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PropertyValidator(Class<?>... groups)PropertyValidator(Property property, Class<?>... groups)PropertyValidator(Property property, org.apache.wicket.model.IModel<Class<?>[]> groups)PropertyValidator(org.apache.wicket.model.IModel<Class<?>[]> groups)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(org.apache.wicket.Component component)voiddetach(org.apache.wicket.Component component)protected booleanisRequired()Should this property make the owning component required.voidonComponentTag(org.apache.wicket.Component component, org.apache.wicket.markup.ComponentTag tag)voidonConfigure(org.apache.wicket.Component component)voidvalidate(org.apache.wicket.validation.IValidatable<T> validatable)
-
-
-
Constructor Detail
-
PropertyValidator
public PropertyValidator(Class<?>... groups)
-
PropertyValidator
public PropertyValidator(org.apache.wicket.model.IModel<Class<?>[]> groups)
-
PropertyValidator
public PropertyValidator(Property property, Class<?>... groups)
-
PropertyValidator
public PropertyValidator(Property property, org.apache.wicket.model.IModel<Class<?>[]> groups)
-
-
Method Detail
-
bind
public void bind(org.apache.wicket.Component component)
- Overrides:
bindin classorg.apache.wicket.behavior.Behavior
-
onConfigure
public void onConfigure(org.apache.wicket.Component component)
- Overrides:
onConfigurein classorg.apache.wicket.behavior.Behavior
-
detach
public void detach(org.apache.wicket.Component component)
- Overrides:
detachin classorg.apache.wicket.behavior.Behavior
-
isRequired
protected boolean isRequired()
Should this property make the owning component required.- Returns:
trueif required- See Also:
BeanValidationContext.isRequiredConstraint(ConstraintDescriptor)
-
onComponentTag
public void onComponentTag(org.apache.wicket.Component component, org.apache.wicket.markup.ComponentTag tag)
- Overrides:
onComponentTagin classorg.apache.wicket.behavior.Behavior
-
-