[MGNLUI-3592] CheckBoxFieldFactory throws null pointer if i18n is enabled in the form but disabled in the system Created: 17/Sep/15  Updated: 29/Sep/22  Resolved: 02/Oct/15

Status: Closed
Project: Magnolia UI
Component/s: forms
Affects Version/s: 5.3.10
Fix Version/s: 5.3.12

Type: Bug Priority: Minor
Reporter: Richard Gange Assignee: Sang Ngo Huu
Resolution: Fixed Votes: 0
Labels: support
Remaining Estimate: 0d
Time Spent: 0.75d
Original Estimate: 0.75d

Issue Links:
causality
relation
is related to MGNLUI-3451 Checkbox doesn't preserve default val... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: I18n fields issues
Sprint: Basel 13
Story Points: 2

 Description   
    @Override
    public Field<Boolean> createField() {
        super.createField();
        if (definition.isI18n()) {
            if (item instanceof JcrItemAdapter) {
                javax.jcr.Item jcrItem = ((JcrItemAdapter) item).getJcrItem();
                if (jcrItem.isNode()) {
                    Node node = (Node) jcrItem;
                    List<Locale> locales = i18nAuthoringSupport.getAvailableLocales(node);
                    Locale defaultLocale = getDefaultLocale(node);
                    for (Locale locale : locales) {
                        if (!locale.getLanguage().equals(defaultLocale.getLanguage())) {
                            Property<?> property = initializeLocalizedProperty(locale);
                            setPropertyDataSourceAndDefaultValue(property);
                        }
                    }
                }
            }
        }

        return field;
    }

If i18n support is enabled on the form; but not in system itself the for loop causes a null pointer as locales are null.

There are two options to fix:

  • enable i18n support on system level
  • disable i18n inside the form


 Comments   
Comment by Sang Ngo Huu [ 25/Sep/15 ]

I18n inside form should be disabled if system's i18n is disabled. At current, other fields supported this case. Just checkbox not.

Comment by Ilgun Ilgun [ 29/Sep/15 ]

Please, write a test case for this.

Generated at Mon Feb 12 09:08:10 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.