Announcement

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

    DataSourceEnumField potential bug with validation warnings

    Hello,

    I've found a problem with validation errors when field is created as DataSourceEnumField and using `when` conditions.
    See this test case:
    Code:
            DataSource ds = new DataSource();
            ds.setClientOnly(true);
    
            DataSourceIntegerField fieldId = new DataSourceIntegerField("id");
            fieldId.setPrimaryKey(true);
            ds.addField(fieldId);
            ds.addField(new DataSourceTextField("field1"));
            ds.addField(new DataSourceTextField("field2"));
    
            DataSourceEnumField fieldStatus = new DataSourceEnumField("status");
    
            LinkedHashMap<String,String> map = new LinkedHashMap<String,String>();
            map.put("new", "NEW");
            map.put("progress", "Progress");
            map.put("finished", "Finished");
            map.put("canceled", "Canceled");
            fieldStatus.setValueMap(map);
    // fieldStatus.setValueMap("new", "progress", "finished", "canceled");
            ds.addField(fieldStatus);
    
            VLayout layout1 = new VLayout(5);
            layout1.setGroupTitle("vm1");
    
            ValuesManager vm1 = new ValuesManager();
            vm1.setDataSource(ds);
    
            DynamicForm form1 = new DynamicForm();
            form1.setDataSource(ds);
            form1.setValuesManager(vm1);
    
            TextItem itemField1 = new TextItem("field1");
            itemField1.setReadOnlyWhen(new AdvancedCriteria("status", OperatorId.IN_SET, new String[] {"finished", "canceled"}));
    
            SelectItem itemStatus = new SelectItem("status");
            itemStatus.setRedrawOnChange(true);
    
            form1.setFields(
                    new TextItem("id"),
                    itemField1,
                    itemStatus
            );
            layout1.addMember(form1);
    
            DynamicForm form2 = new DynamicForm();
            form2.setDataSource(ds);
            form2.setValuesManager(vm1);
    
            TextItem itemField2 = new TextItem("field2");
            itemField2.setReadOnlyWhen(new AdvancedCriteria("status", OperatorId.IN_SET, new String[] {"finished", "canceled"}));
    
            form2.setFields(
                    itemField2
            );
            layout1.addMember(form2);
    
            this.addChild(layout1);
    Running this code and changing status field value creates multiple warnings in console:
    Code:
    TMR6:WARN:validation:isOneOf validator specified with no specified list of options or valueMap - validator will always fail. Field definition:null
    When just changing DataSourceEnumField to DataSourceTextField all warnings disappear.

    Best regards
    Mariusz Goch
Working...
X