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

Runtime Exception when trying to convert an Enum to a String

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • 5.2.4
    • forms
    • None

      Vaadin does not provide one StringToEnumConvert by default so this is what one gets when trying to display an Enum property in a text field.

      Caused by: com.vaadin.data.util.converter.Converter$ConversionException: Unable to convert value of type info.magnolia.task.Task$Status to presentation type class java.lang.String. No converter is set and the types are not compatible.
      	at com.vaadin.data.util.converter.ConverterUtil.convertFromModel(ConverterUtil.java:116)
      	at com.vaadin.ui.Label.getDataSourceValue(Label.java:187)
      	at com.vaadin.ui.Label.setPropertyDataSource(Label.java:260)
      	at info.magnolia.ui.form.field.factory.AbstractFieldFactory.getView(AbstractFieldFactory.java:205)
      	at info.magnolia.ui.dialog.formdialog.FormBuilder.buildView(FormBuilder.java:135)
      

      The fix consists in creating a simple Converter and add a check in AbstractFieldFactory.getView(..) (see attached patch)

        Acceptance criteria

              Unassigned Unassigned
              fgrilli Federico Grilli
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD