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 or string collection fields of display from fields of record with the same name but formatted according to the conversion annotations, such as IntegerConversion, 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.

      For each display field, the exact behaviour depends on it, the matching record field, and conversion annotation.

        Display field
      Source field Single value Array Collection
      Single value Yes
      Array Yes Yes
      Collection Yes1 Yes Yes
      Display formatting modes

      1 Uses collection converter instead.

      Miscellaneous notes.

    • updateDisplayWithPolicyLookup

      public static void updateDisplayWithPolicyLookup(Class<?> recordClass, Object record, Object display, PolicyLookup policyLookup)

      Same as #updateDisplay but can use a different set of formatters.