Class AbstractFormValidator

java.lang.Object
org.apache.wicket.behavior.Behavior
org.apache.wicket.markup.html.form.validation.AbstractFormValidator
All Implemented Interfaces:
Serializable, IComponentAwareEventSink, IFormValidator, IComponentAwareHeaderContributor, IClusterable
Direct Known Subclasses:
EqualInputValidator

public abstract class AbstractFormValidator extends Behavior implements IFormValidator
Base class for IFormValidators.
Author:
Igor Vaynberg (ivaynberg)
See Also:
  • Constructor Details

  • Method Details

    • bind

      public void bind(Component component)
      Can be bound to Forms only.
      Overrides:
      bind in class Behavior
      Parameters:
      component - the component to bind to
      Throws:
      WicketRuntimeException - if component is not a form
    • error

      public void error(FormComponent<?> fc)
      Reports an error against validatable using the map returned by variablesMap()for variable interpolations and message key returned by resourceKey().
      Parameters:
      fc - form component against which the error is reported
    • error

      public void error(FormComponent<?> fc, String resourceKey)
      Reports an error against the validatable using the given resource key
      Parameters:
      fc - form component against which the error is reported
      resourceKey - The message resource key to use
    • error

      public void error(FormComponent<?> fc, Map<String,Object> vars)
      Reports an error against the validatable using the given map for variable interpolations and message resource key provided by resourceKey()
      Parameters:
      fc - form component against which the error is reported
      vars - variables for variable interpolation
    • error

      public void error(FormComponent<?> fc, String resourceKey, Map<String,Object> vars)
      Reports an error against the validatable using the specified resource key and variable map
      Parameters:
      fc - form component against which the error is reported
      resourceKey - The message resource key to use
      vars - The model for variable interpolation
    • variablesMap

      protected Map<String,Object> variablesMap()
      Gets the default variables for interpolation. These are for every component:
      • ${input(n)}: the user's input
      • ${name(n)}: the name of the component
      • ${label(n)}: the label of the component - either comes from FormComponent.labelModel or resource key [form-id].[form-component-id] in that order
      Returns:
      a map with the variables for interpolation
    • resourceKey

      protected String resourceKey()
      Gets the resource key for validator's error message from the ApplicationSettings class.
      Returns:
      the resource key based on the form component