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

ClassCastException when validating ComboBox item

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Neutral
    • Resolution: Not an issue
    • Affects Version/s: None
    • Fix Version/s: 6.0
    • Component/s: None
    • Labels:
      None

      Description

      This is a follow-up issue to MGNLUI-4519. To reproduce

      • enable the new content-app.yml's configuration for a single select (combo box) i.e.
        class: info.magnolia.ui.databinding.definition.JcrSingleSelectFieldDefinition
         datasource:
          class: info.magnolia.ui.datasource.jcr.JcrDatasourceDefinition
          workspace: contacts
          describeByProperty: lastName
          allowedNodeTypes:
          - mgnl:contact 
        
      • try to select an item

      The following ClassCastException occurs

        Caused by: java.lang.ClassCastException: Cannot cast java.lang.String to javax.jcr.Node
              	at java.lang.Class.cast(Class.java:3369) ~[?:1.8.0_131]
              	at com.vaadin.data.Binder$BindingBuilderImpl.lambda$createConverter$f6099586$1(Binder.java:864) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Converter.lambda$null$fdd4de71$1(Converter.java:105) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Result.of(Result.java:91) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Converter.lambda$from$28ca080b$1(Converter.java:105) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Converter$1.convertToModel(Converter.java:131) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Converter$2.lambda$convertToModel$5daf174e$1(Converter.java:167) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.SimpleResult.flatMap(SimpleResult.java:66) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.ValidationResultWrap.flatMap(ValidationResultWrap.java:66) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Converter$2.convertToModel(Converter.java:167) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Binder$BindingImpl.doConversion(Binder.java:1097) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Binder$BindingImpl.doValidation(Binder.java:1114) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Binder$BindingImpl.validate(Binder.java:1061) ~[vaadin-server-8.4.2.jar:8.4.2]
              	at com.vaadin.data.Binder$Binding.validate(Binder.java:135) ~[vaadin-server-8.4.2.jar:8.4.2]
      

      From a first debugging session it looks something is wrong with the binding configuration. Upon selecting an item, the Vaadin's validation process kicks in and chained converters are invoked. At some point, JcrItemToLinkConverter is called and correctly converts the presentation type (JCR Node) into its model (an identifier, i.e. String). Then, other validators are called and some internal Vaadin converter expects again a Node but gets a String, hence ClassCastEx. Possibly the binding per locale implementation is messing up things due to an incomplete converter configuration?

      See info.magnolia.ui.framework.databinding.view.FormView as a starting point for the logic creating the Binder per Locale.

        Checklists

        Acceptance criteria

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Checklists

                    Task DoR