Annotation Type BooleanConversion


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

Defines a form field (whether on a Struts Action or model of ModelDriven Struts Action) should be converted to a boolean or Boolean type. The value parses to true if it starts with '1', 't' or 'y' (lowercase or uppercase), otherwise false. No error message can happen. Also, defines a view helper field receives a formatted boolean value. This is the default converter for boolean and Boolean fields.

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

Conversion Annotation Usage
Form field type Conversion mode Description
Boolean or boolean single value Auto conversion Converts directly from request parameter of the same name
Boolean or boolean array or collection Auto conversion Converts each request parameter of the same name and creates and sets array or collection
String single value Pair conversion Converts string field value to Boolean or boolean field named by parsedFieldName
String array or collection Pair conversion Converts each string field value, creates and sets Boolean or boolean array or collection field named by parsedFieldName

Other parameters

Other Parameters
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 validate empty string. Defaults to true.

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
String single value boolean or Boolean single value
String array or collection boolean or Boolean array or collection
  • Element Details

    • parsedFieldName

      String parsedFieldName
      Default:
      ""
    • processNoValue

      boolean processNoValue
      Default:
      true