Class StrutsMiscellaneousLibrary

java.lang.Object
name.matthewgreet.strutscommons.util.StrutsMiscellaneousLibrary

public class StrutsMiscellaneousLibrary extends Object
Various static library functions for use by library clients not covered other libraries.
  • Constructor Details

    • StrutsMiscellaneousLibrary

      public StrutsMiscellaneousLibrary()
  • Method Details

    • formatForm

      public static <T> void formatForm(Object form)
      Formats the annotated form fields from the associated, unformatted halves of every formatted/unformatted field pair. See BooleanConversion, 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

      public static StrutsMiscellaneousLibrary.FormattedFormsResult getFormattedForms()
      Returns the formatted forms created by FormFormatterInterceptor. As these are only created by a Struts 2 pre-result listener set by the Interceptor, no result is available till then.
    • updateDisplay

      public static void updateDisplay(Class<?> recordClass, Object record, Object display)

      Sets string fields of display from fields of record with the same name but formatted according to the conversion annotations on display fields, or default converter if no annotation. If record is null, recipient display 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 or AbstractCustomCollectionFormatterSupport.
      • The default converters for booleans and enumerations don't format to user friendly text, so custom converters are better.
      • Does not follow associations.