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

Remove generic type of default value in ValueBoundProperty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 6.2.9
    • 6.2.4
    • None

      Currently the default value type in ValueBoundProperty is bound with the presentation type of the field (generic <T>), but it is typically something else (i.e. the model type).

      E.g. presentation value of the JCR selects is the Node but the default value is specified as a string.

      Symptoms

      The problem is most prominent when there is a converter between the model and the presentation types is preset. E.g. this:

      field: 
           $type: textField
           type: java.lang.Long
           converterClass: com.vaadin.data.converter.StringToLongConverter
           defaultValue: !!java.lang.Long 0
      

      In the snippet above will cause a CCE for the following reasons:

      • SnakeYAML will read the number as hinted by the tag
      • Map2Bean will resolve the generic default value type (via getter/setter signature and BeanIntrospection)
      • M2B will consequently convert a number to a string and will feed it to the converter chain upon field initialisation, converter will fail.

      Solution:

      • Be explicit about the type of the default value (by implementing MGNLUI-6374)?
      • Be more flexible when setting the default value? I.e. in FormPresenter - do not assume that the value is in "model" form, check if the value is already compatible with presentation form. Consider adding presetation type as [pre-configured] definition property? Do we have a use-case for model type property as well?

        Acceptance criteria

              mhaderka Martin Haderka
              apchelintcev Aleksandr Pchelintcev
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - Not Specified
                    Not Specified
                    Logged:
                    Time Spent - 23m
                    23m