Uploaded image for project: 'Java Script UI (App and Dialog Fields)'
  1. Java Script UI (App and Dialog Fields)
  2. JSFIELD-45

FormFieldsExtractor unable to resolve compositeField in switchableField for non-default language in FormViewWithChangeListener-form

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 2.0.3
    • 2.0.2
    • None

      Steps to reproduce

      1. Make sure the used test-site uses at least two locales (in our case de + en -> fallbackLocale = de) + DefaultI18nContentSupport
      2. Create a dialog with at least one of these:
        • i18n-enabled switchableField that includes a compositeField

        • javascriptField (+ html file for fieldScript, can be left empty)

       

      form:
        implementationClass: info.magnolia.ui.javascript.form.FormViewWithChangeListener
        $type: tabbedForm
        tabs:
          general:
            label: 'General'
            fields:
              switchableField:
                label: 'Switchable Field'
                i18n: true
                $type: switchableField
                itemProvider:
                  $type: jcrChildNodeProvider
                field:
                  $type: radioButtonGroupField
                  layout: horizontal
                  defaultValue: option
                  datasource:
                    $type: optionListDatasource
                    options:
                      - name: option
                        value: option
                        label: 'Option'
                forms:
                  option:
                    properties:
                      option:
                        $type: compositeField
                        label: 'Sub Composite Field'
                        itemProvider:
                          $type: jcrChildNodeProvider
                        properties:
                          text:
                            label: 'Text'
                            $type: textField
                            required: true
      
              javascriptField:
                $type: javascriptField
                fieldScript: /whatever-path-floats-your-boat/webresources/dialogs/components/custom-chooser.html
                height: 200
                parameters:
                  field: javascriptFieldValue
      

       

      1. Open the dialog with fallbackLocale (de)
      2. Switch Locales in bottom left dropdown menu (to en)

      Expected results

      Dialog should look the same as German version, just with language specific field values.

      Actual results

      Error gets shown in CMS + Logs reveals strack-trace with the root cause being a NullPointerException occurring in FormFieldsExtractor.

      (See following file for stacktrace: stacktrace.log)

      Workaround

      Error can be circumvented by explicitly adding "i18n: true" to the "Sub Composite Field".

      Development notes

      The error originates from "FormfieldsExtractor.getCompositeFormFields" which tries to get the appropriate representation from the subEditor.

      Since i18n is not enabled for "option" (= "Sub Composite Field") it tries resolving to default-locale.

      Since the representations only contain the key "en" though it resolves to null, which gets passed along to "getFormFields(...)" then "getSimpleFormFields(...)" and finally results in the attempted FormPresenter-resolution via "FormViewIntrospector.getFormPresenter(formView)" -> chained ".getBoundFields(locale)" then throws a NullPointerException.

        Acceptance criteria

              tmiyar Teresa Miyar
              sandal Luca Sanda
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: