Class 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 using BeanValidationConfiguration.

    The validator must be provided a Property, unless one can be resolved from the component implicitly. By default the configuration contains the DefaultPropertyResolver so PropertyModels 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 to true, components with the required flag already set to true will not have the flag set to false by this validator.

    The validator will allow ITagModifiers registered on BeanValidationContext to mutate the markup tag of the component it is attached to, e.g. add a maxlength attribute.

    The validator specifies default error messages in the PropertyValidator.properties file. 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
    • Method Detail

      • bind

        public void bind​(org.apache.wicket.Component component)
        Overrides:
        bind in class org.apache.wicket.behavior.Behavior
      • onConfigure

        public void onConfigure​(org.apache.wicket.Component component)
        Overrides:
        onConfigure in class org.apache.wicket.behavior.Behavior
      • detach

        public void detach​(org.apache.wicket.Component component)
        Overrides:
        detach in class org.apache.wicket.behavior.Behavior
      • onComponentTag

        public void onComponentTag​(org.apache.wicket.Component component,
                                   org.apache.wicket.markup.ComponentTag tag)
        Overrides:
        onComponentTag in class org.apache.wicket.behavior.Behavior
      • validate

        public void validate​(org.apache.wicket.validation.IValidatable<T> validatable)
        Specified by:
        validate in interface org.apache.wicket.validation.IValidator<T>