[MGNLUI-3451] Checkbox doesn't preserve default value upon switching to another language Created: 04/Jun/15  Updated: 17/Sep/15  Resolved: 30/Jun/15

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

Type: Bug Priority: Major
Reporter: Zdenek Skodik Assignee: Evzen Fochr
Resolution: Fixed Votes: 0
Labels: support
Remaining Estimate: 0d
Time Spent: 7h
Original Estimate: Not Specified

Issue Links:
Relates
relation
is related to MGNLUI-3592 CheckBoxFieldFactory throws null poin... Closed
is related to MGNLUI-3490 Investigate the possibility to stream... Closed
supersession
is superseded by MGNLUI-3489 Support field default value for local... 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: Form field attributes handling

 Description   

Configuring selected=true, or defaultValue=true eventually, doesn't guarantee the checkbox to be ticked when the language in dialog is switched.



 Comments   
Comment by Evzen Fochr [ 29/Jun/15 ]

Only possible solution i see is that for i18ned components we initialize property with default value for every language while opening dialog. (AbstractFieldFactory.createField)

Comment by Michael Mühlebach [ 01/Jul/15 ]

You could implement it in the Transformer. It should have a ref to the field definition. And for example in the BasicTransformer a good place to set the default value might be #getOrCreateProperty()
This change might replace the default value logic in the AbstractFieldFactory#setPropertyDataSourceDefaultValue(). Some backward compatibility issue could prevent it.

Comment by Evzen Fochr [ 01/Jul/15 ]

Its done in CheckboxFieldFactory, because i want to do it only for checkboxes. If it is done in BasicTransformer, it is changed for all components. I am not sure about this large scale change.

Comment by Ilgun Ilgun [ 08/Jul/15 ]

CheckBoxFieldFactory

  • We should not be duplicating the code especially if it is that easy to get it from Abstract class such as;
protected Class<? extends Transformer<?>> getTransformerClass() {
        Class<? extends Transformer<?>> transformerClass = definition.getTransformerClass();

        if (transformerClass == null) {
            // TODO explain why down cast
            transformerClass = (Class<? extends Transformer<?>>) (Object) BasicTransformer.class;
        }
        return transformerClass;
    }

        private Property<?> initializeLocalizedProperty(Locale locale) {
        Class<? extends Transformer<?>> transformerClass = getTransformerClass();
        Transformer<?> transformer = initializeTransformer(transformerClass);
        }
  • Please suppress the unchecked warnings.
  • Please format your code.

CheckBoxFieldFactoryTest

  • List<Locale> locales = new ArrayList<Locale>(); -> can be newArrayList(); we do not need to specify arrayList type.
  • Please format your code.
  • array-list can be initialised with the values directly such as; List<Locale> locales = newArrayList(en,de);
  • why initialising field if it is not going to be used after;
    Field<Boolean> field = checkBoxField.createField();

instead should be: checkBoxField.createField(;

  • if this test will be duplicated in all test methods then why not doing it one time in Test.setup().
    checkBoxField = new CheckBoxFieldFactory(definition, baseItem);
    checkBoxField.setComponentProvider(new MockComponentProvider());
Generated at Mon Feb 12 09:06:44 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.