Annotation Type IntegerConversion
Defines a form field (whether on a Struts Action or model of ModelDriven Struts Action) should be parsed to a int or Integer type and error message to display if this fails. Also, defines a view helper field receives a formatted integer value. This is the default converter for int and Integer fields.
There are various modes of behaviour for conversion, depending on the type of form field.
| Form field type | Conversion mode | Description |
|---|---|---|
| Integer or int single value | Auto conversion | Converts directly from request parameter of the same name |
| Integer or int 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 Integer or int field named by parsedFieldName |
| String array or collection | Pair conversion | Converts each string field value, creates and sets Integer or int array or collection field named by parsedFieldName |
By default, messages are written as Action error messages for form processing Actions and logged as warnings for
viewer Actions but this can be overridden by messageType. For viewer Actions, it's recommended they
implement LoggingAware (which AbstractViewActionSupport already does).
| DEFAULT | Uses default setting of controlling interceptor or library, which is usually Action error messages for form processing Actions and logged as warnings for view ActionsMessage. Default. |
| ERROR | Message added to Action level error messages. |
| FIELD | Message added to field error messages using same name as field. |
| IGNORE | Message is not shown to user or logged. This is not recommended. |
| LOG_DEBUG | Logged to Action's Log4j2 logger (or controlling interceptor's if not available) at DEBUG level. |
| LOG_ERROR | Logged to Action's Log4j2 logger (or controlling interceptor's if not available) at ERROR level. |
| LOG_INFO | Logged to Action's Log4j2 logger (or controlling interceptor's if not available) at INFO level. |
| LOG_TRACE | Logged to Action's Log4j2 logger (or controlling interceptor's if not available) at TRACE level. |
| LOG_WARN | Logged to Action's Log4j2 logger (or controlling interceptor's if not available) at WARN level. |
| MESSAGE | Message added to Action level info messages. |
| WARNING | Message added to Action level warning messages. |
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. |
| 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. |
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.
| Display field type | Record field type |
|---|---|
| String single value | int or Integer single value |
| String array or collection | int or Integer array or collection |
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescription
-
Element Details
-
message
String message- Default:
""
-
messageKey
String messageKey- Default:
""
-
messageType
Required.MessageType messageType- Default:
DEFAULT
-
parsedFieldName
String parsedFieldName- Default:
""
-