Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom SimpleType updateAtomicValue result not stored

    Hi,

    When using a custom SimpleType on a datasource field the updateAtomicValue of the SimpleTypeValueUpdater is used but when the editor is exited then the updated value seems to not be stored.

    Tested using v14.1p_2026-06-11/Pro Deployment, in the latest version of the Chrome browser.
    Test case:
    Code:
    @Override
        public void onModuleLoad()
        {
            SimpleType type = new SimpleType("joinedValues", FieldType.TEXT);
            type.setSimpleTypeValueExtractor(new SimpleType.SimpleTypeValueExtractor()
            {
                @Override
                public Object getAtomicValue(Object value)
                {
                    Object atomicValue = value;
                    if (value instanceof String)
                    {
                        String s = (String) value;
                        atomicValue = s.isEmpty() ? new String[0] : s.split("\\|");
                    }
    
                    return atomicValue;
                }
            });
    
            type.setSimpleTypeValueUpdater(new SimpleType.SimpleTypeValueUpdater()
            {
                @Override
                public Object updateAtomicValue(Object atomicValue, Object currentValue)
                {
                    Object updatedValue = atomicValue;
                    if (atomicValue instanceof String[])
                    {
                        updatedValue = Arrays.stream((String[]) atomicValue).collect(Collectors.joining("|"));
                    }
                    else if (atomicValue instanceof List<?>)
                    {
                        List<String> list = (List<String>) atomicValue;
                        updatedValue = list.stream().collect(Collectors.joining("|"));
                    }
    
                    return updatedValue;
                }
            });
    
            Map<String, String> valueMap = new LinkedHashMap<>();
            valueMap.put("InternalA", "ExternalA");
            valueMap.put("InternalB", "ExternalB");
            valueMap.put("InternalC", "ExternalC");
    
            DataSource ds = new DataSource();
            ds.setClientOnly(true);
    
            DataSourceField pkField = new DataSourceTextField("A");
            pkField.setPrimaryKey(true);
    
            DataSourceField testField = new DataSourceField("B", FieldType.TEXT);
            testField.setType(type);
            testField.setEditorProperties(new MultiPickerItem());
            testField.setValueMap(valueMap);
            testField.setCanEdit(true);
    
            ds.setFields(pkField, testField);
    
            ListGrid listGrid = new ListGrid();
            listGrid.setDataSource(ds);
            listGrid.setCanEdit(true);
            listGrid.setWidth("100%");
    
            ListGridRecord record = new ListGridRecord();
            record.setAttribute("A", "PkA");
            record.setAttribute("B", "InternalA|InternalC");
            ds.setCacheData(record);
            listGrid.fetchData();
    
            listGrid.draw();
        }
    Scenario: In our application we have a field with strings like "A|B|C" that we want the user to edit using a MultiPickerItem which seems to expect an array of values. The received and later saved value needs to stay in this format so the SimpleType with a value extractor/updater seems like a perfect fit.

    I'm not sure but maybe the issue could be in performActionOnValue(). It looks like the update of the record value is not done if the field has a simple type that uses updateAtomicValue:

    Click image for larger version

Name:	sgwt_simpletype_01.png
Views:	10
Size:	177.9 KB
ID:	277704


    I also noticed some warnings in the console when trying to edit in this test case:
    Click image for larger version

Name:	sgwt_simpletype_04.png
Views:	14
Size:	81.2 KB
ID:	277703

    #2
    Thanks for the report - we see the issue and a fix has been made.

    Please retry with tomorrow's builds, dated July 9, or later.

    Comment


      #3
      Thanks for the quick fix, has this fix also been ported to 14.1p? Latest build I see is July 8th:
      Click image for larger version

Name:	sgwt_builds.png
Views:	0
Size:	15.3 KB
ID:	277711

      Comment


        #4
        Yes it was ported to 14.1 - we had an issue with the builds yesterday, but you should see today's builds arrive as usual in the early PM UTC.

        Comment

        Working...
        X