[JSFIELD-45] FormFieldsExtractor unable to resolve compositeField in switchableField for non-default language in FormViewWithChangeListener-form Created: 15/Sep/23  Updated: 24/Jan/24  Resolved: 11/Oct/23

Status: Closed
Project: Java Script UI (App and Dialog Fields)
Component/s: None
Affects Version/s: 2.0.2
Fix Version/s: 2.0.3

Type: Bug Priority: Neutral
Reporter: Luca Sanda Assignee: Teresa Miyar
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File stacktrace.log    
Template:
Acceptance criteria:
[ ]* Error should no longer be thrown + getFormFields(...) should still resolve fields properly

 Description   

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.


Generated at Mon Feb 12 02:16:34 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.