Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-3772

Support BeanItems with enum members

XMLWordPrintable

    • Yes
    • Yes
    • Saigon 56
    • 8

      Many small apps use our form framework (vs. plain Vaadin forms) to build forms from configuration, and benefit from validation styles.

      It is then possible to use the form framework with Vaadin BeanItems, for example.

      However, it is not possible to "bind" an OptionGroup field to an enum member of a BeanItem. Several reasons for that:

      • Transformers are initialized anyway, and try to #setValue on the underlying property (e.g. MethodProperty), with potential incompatible types.
        • Transformers actually make very little sense for BeanItems, that would be super convoluted
      • OptionGroup will want to use a String for value presentation anyway, so we need a Converter
        • We can set a converterClass already, though Vaadin's StringToEnumConverter is a no-go, since it humanizes and localizes the presentation already (we use a different caption mode)
        • Instead, we need a simple/stupid converter from the enum to its name(), and back, and we do need that String here, because the option values come from config.
      • Finally, default value doesn't work when value and property types are incompatible—even when a converterClass is configured
        • there we can add a fallback to tentatively solve that

      If for some reason we don't want to do any of the above, one has to resort in using booleans or Strings in BeanItems, which is simply less elegant.

      Finally, if our form-framework were more elegant (e.g. wrapping plain Vaadin forms, or not self-imposing itself just for the sake of validation bubbles), this would surely be a lot more trivial: such binding takes less than 5 minutes to do with plain Vaadin.

        Acceptance criteria

              mgeljic Mikaël Geljić
              mgeljic Mikaël Geljić
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD

                    Estimated:
                    Original Estimate - 3.5h
                    3.5h
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 3.5h
                    3.5h