org.apache.struts2.components

## Class Form.FieldVisitorValidatorWrapper

- java.lang.Object
- - org.apache.struts2.components.Form.FieldVisitorValidatorWrapper

- All Implemented Interfaces:
    FieldValidator, Validator
  Enclosing class:
    Form

      public static class Form.FieldVisitorValidatorWrapper
      extends Object
      implements FieldValidator

  Wrap field validator, add visitor's field prefix to the field name. Javascript side is not aware of the visitor validators and does not know how to prefix the fields.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FieldVisitorValidatorWrapper(FieldValidator fv, String namePrefix)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getDefaultMessage()` Gets the default message used for validation failures
    `String` | `getFieldName()` Gets the field name to be validated
    `FieldValidator` | `getFieldValidator()`
    `String` | `getMessage(Object object)` Gets the validation failure message for the given object
    `String` | `getMessageKey()` Gets the resource bundle key used for lookup of validation failure message
    `String[]` | `getMessageParameters()` Gets the message parameters to be used when parsing i18n messages
    `String` | `getNamePrefix()`
    `ValidatorContext` | `getValidatorContext()` Gets the validation context used
    `String` | `getValidatorType()` Gets the validator type used (see class javadoc).
    `void` | `setDefaultMessage(String message)` Sets the default message to use for validation failure
    `void` | `setFieldName(String fieldName)` Sets the field name to validate with this FieldValidator
    `void` | `setFieldValidator(FieldValidator fieldValidator)`
    `void` | `setMessageKey(String key)` Sets a resource bundle key to be used for lookup of validation failure message
    `void` | `setMessageParameters(String[] messageParameters)` Sets the message parameters to be used when parsing i18n messages
    `void` | `setNamePrefix(String namePrefix)`
    `void` | `setValidatorContext(ValidatorContext validatorContext)` This method will be called before validate with a non-null ValidatorContext.
    `void` | `setValidatorType(String type)` Sets the validator type to use (see class javadoc).
    `void` | `setValueStack(ValueStack stack)` Sets the value stack to use to resolve values and parameters
    `void` | `validate(Object object)` The validation implementation must guarantee that setValidatorContext will be called with a non-null ValidatorContext before validate is called.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FieldVisitorValidatorWrapper

          public FieldVisitorValidatorWrapper(FieldValidator fv,
                                              String namePrefix)

  - ### Method Detail

    - #### getValidatorType

          public String getValidatorType()

      Description copied from interface: `Validator`
      Gets the validator type used (see class javadoc).
      Specified by:
        `getValidatorType` in interface `Validator`
      Returns:
        the type used

    - #### getFieldName

          public String getFieldName()

      Description copied from interface: `FieldValidator`
      Gets the field name to be validated
      Specified by:
        `getFieldName` in interface `FieldValidator`
      Returns:
        the field name

    - #### getFieldValidator

          public FieldValidator getFieldValidator()

    - #### setFieldValidator

          public void setFieldValidator(FieldValidator fieldValidator)

    - #### getDefaultMessage

          public String getDefaultMessage()

      Description copied from interface: `Validator`
      Gets the default message used for validation failures
      Specified by:
        `getDefaultMessage` in interface `Validator`
      Returns:
        the default message

    - #### getMessage

          public String getMessage(Object object)

      Description copied from interface: `Validator`
      Gets the validation failure message for the given object
      Specified by:
        `getMessage` in interface `Validator`
      Parameters:
        `object` - object being validated (eg. a domain model object)
      Returns:
        the validation failure message

    - #### getMessageKey

          public String getMessageKey()

      Description copied from interface: `Validator`
      Gets the resource bundle key used for lookup of validation failure message
      Specified by:
        `getMessageKey` in interface `Validator`
      Returns:
        the resource bundle key

    - #### getMessageParameters

          public String[] getMessageParameters()

      Description copied from interface: `Validator`
      Gets the message parameters to be used when parsing i18n messages
      Specified by:
        `getMessageParameters` in interface `Validator`
      Returns:
        the message parameters

    - #### getValidatorContext

          public ValidatorContext getValidatorContext()

      Description copied from interface: `Validator`
      Gets the validation context used
      Specified by:
        `getValidatorContext` in interface `Validator`
      Returns:
        the validation context

    - #### setDefaultMessage

          public void setDefaultMessage(String message)

      Description copied from interface: `Validator`
      Sets the default message to use for validation failure
      Specified by:
        `setDefaultMessage` in interface `Validator`
      Parameters:
        `message` - the default message

    - #### setFieldName

          public void setFieldName(String fieldName)

      Description copied from interface: `FieldValidator`
      Sets the field name to validate with this FieldValidator
      Specified by:
        `setFieldName` in interface `FieldValidator`
      Parameters:
        `fieldName` - the field name

    - #### setMessageKey

          public void setMessageKey(String key)

      Description copied from interface: `Validator`
      Sets a resource bundle key to be used for lookup of validation failure message
      Specified by:
        `setMessageKey` in interface `Validator`
      Parameters:
        `key` - the resource bundle key

    - #### setMessageParameters

          public void setMessageParameters(String[] messageParameters)

      Description copied from interface: `Validator`
      Sets the message parameters to be used when parsing i18n messages
      Specified by:
        `setMessageParameters` in interface `Validator`
      Parameters:
        `messageParameters` - the message parameters

    - #### setValidatorContext

          public void setValidatorContext(ValidatorContext validatorContext)

      Description copied from interface: `Validator`
      This method will be called before validate with a non-null ValidatorContext.
      Specified by:
        `setValidatorContext` in interface `Validator`
      Parameters:
        `validatorContext` - the validation context to use.

    - #### setValidatorType

          public void setValidatorType(String type)

      Description copied from interface: `Validator`
      Sets the validator type to use (see class javadoc).
      Specified by:
        `setValidatorType` in interface `Validator`
      Parameters:
        `type` - the type to use.

    - #### setValueStack

          public void setValueStack(ValueStack stack)

      Description copied from interface: `Validator`
      Sets the value stack to use to resolve values and parameters
      Specified by:
        `setValueStack` in interface `Validator`
      Parameters:
        `stack` - The value stack for the request

    - #### validate

          public void validate(Object object)
                        throws ValidationException

      Description copied from interface: `Validator`
      The validation implementation must guarantee that setValidatorContext will be called with a non-null ValidatorContext before validate is called.
      Specified by:
        `validate` in interface `Validator`
      Parameters:
        `object` - the object to be validated.
      Throws:
        `ValidationException` - is thrown if there is validation error(s).

    - #### getNamePrefix

          public String getNamePrefix()

    - #### setNamePrefix

          public void setNamePrefix(String namePrefix)

Copyright © 2000–2026 Apache Software Foundation. All rights reserved.