Class StrutsMiscellaneousLibrary
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
formatForm
(Object form) Formats the annotated form fields from the associated, unformatted halves of every formatted/unformatted field pair.static void
For all the current Action's forms, formats the annotated, formatted halves of every formatted/unformatted field pair from the unformatted halves, except for any form that was retrieved and injected (usually a rejected form).Returns the formatted forms created byFormFormatterInterceptor
.static void
updateDisplay
(Class<?> recordClass, Object record, Object display) Sets string fields ofdisplay
from fields ofrecord
with the same name but formatted according to the conversion annotations ondisplay
fields, or default converter if no annotation.
-
Constructor Details
-
StrutsMiscellaneousLibrary
public StrutsMiscellaneousLibrary()
-
-
Method Details
-
formatForm
Formats the annotated form fields from the associated, unformatted halves of every formatted/unformatted field pair. SeeBooleanConversion
,EnumConversion
,IntegerConversion
etc.This is a legacy function and is called by view Struts Actions that don't use the
FormFormatterInterceptor
interceptor. -
formatForms
public static void formatForms()For all the current Action's forms, formats the annotated, formatted halves of every formatted/unformatted field pair from the unformatted halves, except for any form that was retrieved and injected (usually a rejected form). See
BooleanConversion
,EnumConversion
,IntegerConversion
etc.This is a legacy function and is called by view Struts Actions that don't use the
FormFormatterInterceptor
interceptor. -
getFormattedForms
Returns the formatted forms created byFormFormatterInterceptor
. As these are only created by a Struts 2 pre-result listener set by the Interceptor, no result is available till then. -
updateDisplay
Sets string fields of
display
from fields ofrecord
with the same name but formatted according to the conversion annotations ondisplay
fields, or default converter if no annotation. Ifrecord
is null, recipientdisplay
fields are set according to the converter's formatting of null values (usually empty string). This function is useful for displaying database records.Miscellaneous notes.
- Source field type must apply to converter's type.
- Recipient field must be a string, not even string array or string collection.
- Custom converters only for formatting are best derived from
AbstractCustomFormatterSupport
orAbstractCustomCollectionFormatterSupport
. - The default converters for booleans and enumerations don't format to user friendly text, so custom converters are better.
- Does not follow associations.
-