Annotation Type CustomConversion


@Documented @Inherited @Target(FIELD) @Retention(RUNTIME) public @interface CustomConversion

Defines a single value form field (whether on a Struts Action or model of ModelDriven Struts Action) should be converted using a client supplied converter to another and error message to display if this fails. The custom converter must implement Converter, preferably extending AbstractCustomConverterSupport, and have a default public constructor. Also, defines a view helper field receives a value formatted by the converter.

There are two modes of behaviour for conversion, depending on the type of form field.

Validation Annotation Usage
Form field type Mode Description
String Pair conversion Converts string field value field named by parsedFieldName
non-String Auto conversion Converts directly from request parameter

By default, messages are added to the actionErrors list but this can be overridden by messageType:

Message Types
ERROR Message added to Action level error messages. Default.
FIELD Message added to field error messages using same name as field.
MESSAGE Message added to Action level info messages.
WARNING Message added to Action level warning messages.

Other parameters

Other Parameters
message If not empty string, text message to display. Used if messageKey is empty string or finds no message.
messageKey If not empty string, message key to retrieve from Action's TextProvider. Uses message if no key provided or no message found.
param1Parameter recognised by custom validator. Defaults to empty string.
param2Parameter recognised by custom validator. Defaults to empty string.
param3 Parameter recognised by custom validator. Defaults to empty string.
param4 Parameter recognised by custom validator. Defaults to empty string.
param5 Parameter recognised by custom validator. Defaults to empty string.
parsedFieldName If not empty string, name of field to contain parsed value. Defaults to 'parsed' plus capitalised field name, such as 'parsedLimit'. Only applies for pair conversion.
processNoValue If true, can convert empty string and format null value. Defaults to false.
validatorClass Class of client supplied validator. See notes above.

When applied to a view helper field, StrutsMiscellaneousLibrary#updateDisplay formats from a source record field with the same name but only certain combinations are recognised.

Formatting Annotation Usage
Display field type Record field type Notes
String Converter recipient type
String array Array of converter recipient type
String array collection of converter recipient type
String collection Array of converter recipient type
String collection Collection of converter recipient type
  • Element Details

    • message

      String message
      Default:
      ""
    • messageKey

      String messageKey
      Default:
      ""
    • messageType

      Default:
      ERROR
    • param1

      String param1
      Default:
      ""
    • param2

      String param2
      Default:
      ""
    • param3

      String param3
      Default:
      ""
    • param4

      String param4
      Default:
      ""
    • param5

      String param5
      Default:
      ""
    • parsedFieldName

      String parsedFieldName
      Default:
      ""
    • processNoValue

      boolean processNoValue
      Default:
      false
    • validatorClass

      Class<? extends Converter<CustomConversion,?>> validatorClass