Announcement

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

    Form has explicitly specified value for field[s] 'text1', but has no item associated with this fieldName.

    Hi,

    I've come across below warning in some parts of my application.
    Code:
    *20:12:18.354:MUP5:WARN:ValuesManager:isc_ValuesManager_0:Member Form: [DynamicForm ID:isc_DynamicForm_1] has explicitly specified value for field[s] 'text1', but has no item associated with this fieldName. Ignoring this value. Values may be set for fields with no associated form item directly on the valuesManager via valuesManager.setValues(), but not on member forms. See ValuesManager documentation for more info.
    I've done some digging, and it can relate to:
    https://forums.smartclient.com/forum...alue-for-field

    I've managed to create simple test case.

    Code:
    VLayout layout = new VLayout(5);
    
            DataSource ds = new DataSource();
    
            DataSourceIntegerField fieldId = new DataSourceIntegerField("id");
            fieldId.setPrimaryKey(true);
            ds.addField(fieldId);
    
            ds.addField(new DataSourceTextField("display"));
    
            ds.addField(new DataSourceTextField("text1"));
    
            ValuesManager vm = new ValuesManager();
            vm.setDataSource(ds);
    
            DynamicForm form1 = new DynamicForm();
            form1.setDataSource(ds);
            form1.setValuesManager(vm);
    
            form1.setFields(
                    new TextItem("id"),
                    new TextItem("display")
            );
    
            layout.addMember(form1);
    
            DynamicForm form2 = new DynamicForm();
            form2.setDataSource(ds);
            form2.setValuesManager(vm);
    
            form2.setFields(
                    new HiddenItem("id"),
                    new TextItem("text1")
            );
    
            layout.addMember(form2);
    
            Record r = new Record();
            r.setAttribute("id", 1);
            r.setAttribute("display", "aaa");
            r.setAttribute("text1", "bbb");
    
            vm.editRecord(r);
    
            Button button = new Button();
            button.addClickHandler(new ClickHandler() {
    
                @Override
                public void onClick(ClickEvent event) {
                    ListGridRecord r2 = new ListGridRecord();
                    r2.setAttribute("id", 1);
                    r2.setAttribute("display", "aaa1");
                    r2.setAttribute("text1", "bbb1");
    
                    DSResponse dsResponse = new DSResponse();
                    dsResponse.setData(r2);
                    dsResponse.setOperationType(DSOperationType.UPDATE);
                    ds.updateCaches(dsResponse);
                }
            });
    
            layout.addMember(button);
    
            this.addChild(layout);
    As you can see there is a simple DataSource and two forms joined with ValuesManager.
    When clicking on button two warnings appears:
    Code:
    20:12:18.354:MUP5:WARN:ValuesManager:isc_ValuesManager_0:Member Form: [DynamicForm ID:isc_DynamicForm_1] has explicitly specified value for field[s] 'text1', but has no item associated with this fieldName. Ignoring this value. Values may be set for fields with no associated form item directly on the valuesManager via valuesManager.setValues(), but not on member forms. See ValuesManager documentation for more info.
    20:12:18.357:MUP5:WARN:ValuesManager:isc_ValuesManager_0:Member Form: [DynamicForm ID:isc_DynamicForm_2] has explicitly specified value for field[s] 'display', but has no item associated with this fieldName. Ignoring this value. Values may be set for fields with no associated form item directly on the valuesManager via valuesManager.setValues(), but not on member forms. See ValuesManager documentation for more info.
    Similar warning appears when I load record with:
    Code:
    form1.editRecord(r);
    and this is correct. But in above example I think it shouldn't. There are two forms that cover all fields and are connected with ValuesManager.

    In fact this is a simulation of real live example with ValuesManager.saveData() when server responds with whole record. After some debugging I've found that it's connected with updateCaches() method called in core during saveData() processing response.

    Strange thing is that I've used the same schema in several DataSources and in some cases Warning appeared recently (after SmartGWT update from last years version) and in other case it does not. Don't know why is that yet but above minimal case shows a problem.

    I've also tried to connect DynamicForm with ValuesManager with vm.addMember() but behavior did not changed.

    Tested on latest nightly: SmartGWT 13.0p 2023-03-22

    So is this warning correct in above test case and I'm missing something or is it a bug??

    Another thing is when second form will not have hidden field with primary key, after updateCaches() value is not changed. Despite connection with ValuesManager. This is probably desired behavior but I ask to be sure.

    Best regards
    Mariusz Goch

    #2
    Hi there, the error message from your test case isn't as clear as it could be, but it is highlighting a usage issue: you can't have two items editing the same value in two forms that participate in the same ValuesManager. This is because the ValuesManager has no way of knowing which FormItem has the official value.

    If you look at the logs, you may find that, previous to the warning about conflicting values, you have another warning mention conflicting items. One situation leads to the other.

    Regardless, you did mention though, in your real use case, there may be a bogus warning stemming from cache sync. If you can reproduce that, that would be great to see.

    Note that if cache sync can be used to reproduce the issue, then as far as crafting a test case, you don't need to make a complex test case involving a server call and the response - you should be able to reproduce any such problem by using the DataSource.updateCaches() API.

    Comment


      #3
      Hi,

      Real live example works like this:
      1. I've got one ValuesManager with couple forms to show only static values just for read only purpose.
      2. Second ValuesManager with another couple of forms is opened in a window or tab for editing by user.
      3. When a user submits changes in second ValuesManager above warnings are showed. There are no previous warnings.
      4. Expected behavior is to automatically update values in read only ValuesManager.

      What do you mean to items editing same value? Do you refer to id field in form2?
      I've found this problem creating this test case. When I remove id field (primary key) from second form, after updateCaches() is called only first form values are updated.
      This creates a mess because in read only form we've got new values in first form and old values in second one.
      With this situation only one warning is showed because only first form with id field is being updated.

      No previous warnings are showed regarding this test case. See attached screenshot.

      When I think about it, it looks like when updateCaches is processed it updates values on DynamicForm not on ValuesManager. So maybe that's the problem.
      The same warning is showed when I call
      Code:
      form1.editRecord(r);
      instead of
      Code:
      vm.editRecord(r);
      which I think confirms my theory.

      Probably if updateCaches() would work with ValuesManager instead of DynamicForm, id field in second form wouldn't be needed. In fact previously I didn't attached primary key in every form connected with ValuesManager. So maybe there were changes with that behavior some time ago.

      So is desired flow in above example is to update form1 and form2 with values provided to updateCaches() even when form2 does not have primary key field present??
      If so, there is a probably bug in updateCaches() process with should operate on ValuesManager but instead it updates only on form1.

      Best regards
      Mariusz Goch
      Attached Files

      Comment


        #4
        In your test code, you have two forms with the same ValuesManager where two forms have a FormItem for the same field. This is not allowed.

        In your actual app, it sounds like you have two different ValuesManagers, one has a read-only form. That all sounds fine and sounds like it should not cause a warning, but we haven't seen the code, and our related tests don't have this warning.

        So can you show code that reproduces the warning? From what you've said, you should be able to just create a form with a subset of the fields of some DataSource Record, put it in a ValuesManager, and call updateCaches() with the complete Record, and there's the warning. But we don't see that.

        Comment


          #5
          Hi,

          In this test case when form2 does not have id field warning also pops up. I've extended this test case to also show DynamicForm with all fields attached to it.
          Code:
          DataSource ds = new DataSource();
                  DataSourceIntegerField fieldId = new DataSourceIntegerField("id");
                  fieldId.setPrimaryKey(true);
                  ds.addField(fieldId);
                  ds.addField(new DataSourceTextField("field1"));
                  ds.addField(new DataSourceTextField("field2"));
          
                  HLayout hLayout = new HLayout(5);
          
                  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);
                  form1.setFields(
                          new TextItem("id"),
                          new TextItem("field1")
                  );
                  layout1.addMember(form1);
          
                  DynamicForm form2 = new DynamicForm();
                  form2.setDataSource(ds);
                  form2.setValuesManager(vm1);
                  form2.setFields(
                          new TextItem("field2")
                  );
                  layout1.addMember(form2);
          
                  VLayout layout2 = new VLayout(5);
                  layout2.setGroupTitle("vm2");
          
                  ValuesManager vm2 = new ValuesManager();
                  vm2.setDataSource(ds);
          
                  DynamicForm form3 = new DynamicForm();
                  form3.setDataSource(ds);
                  form3.setValuesManager(vm2);
          
                  form3.setFields(
                          new TextItem("id"),
                          new TextItem("field1"),
                          new TextItem("field2")
                  );
          
                  layout2.addMember(form3);
          
                  Record r = new Record();
                  r.setAttribute("id", 1);
                  r.setAttribute("field1", "original1");
                  r.setAttribute("field2", "original2");
          
                  vm1.editRecord(r);
                  vm2.editRecord(r);
          
                  Button button = new Button();
                  button.addClickHandler(new ClickHandler() {
          
                      @Override
                      public void onClick(ClickEvent event) {
                          ListGridRecord r2 = new ListGridRecord();
                          r2.setAttribute("id", 1);
                          r2.setAttribute("field1", "changed1");
                          r2.setAttribute("field2", "changed2");
          
                          DSResponse dsResponse = new DSResponse();
                          dsResponse.setData(r2);
                          dsResponse.setOperationType(DSOperationType.UPDATE);
                          ds.updateCaches(dsResponse);
                      }
                  });
          
                  hLayout.addMember(layout1);
                  hLayout.addMember(layout2);
                  hLayout.addMember(button);
                  this.addChild(hLayout);
          I've attached screenshots after form was loaded and vm.editRecord() is called - original values are visible in all form items in both vm1 and vm2.
          Second screenshot is after on click:
          - warning has showed up regarding vm1 and first form
          - value on field2 in vm1 still shows original value but field1 has changed value
          - value on field2 in vm2 (which contains only one form with all fields) has changed value

          All fields from DataSource are present in ValuesManager but form2 is being ignored.

          Does updateCache process verifies if DynamicForm uses ValuesManager??
          Looking on debug on second screenshot it shows isc_DynamicForm_setValues being called.
          Maybe there should be verification if DynamicForm uses ValuesManager and if it does setValues() should be called on ValuesManager instead of DynamicForm??
          Hope it helps.

          Best regards
          Mariusz Goch
          Attached Files

          Comment


            #6
            Hello,

            Any news on this problem?
            Is there anything I can do to help solve it?

            Best regards
            Mariusz Goch

            Comment


              #7
              Sorry, we have a lot going on right now, and this hasn't bubbled to the top yet (it's been close, but not quite the top).

              Just to clarify - this is just an annoying warning, not a behavior problem, right?

              Also, thanks for the effort creating a clear test case.

              Comment


                #8
                Hello,

                Thank you for your answer.

                No, it's not only warning. As I showed in last test case value of `field2` item in `form2` is not being updated on updateCaches() process. It's only updated when primary key fields are present in this particular DynamicForm. When primary keys exists in other DynamicForm connected with ValuesManager it does not work.

                So this whole functionality to update existing DynamicForms with current data only works when we don't use ValuesManager at all, and use only plain DynamicForm.

                That's why it's not only annoying warning but behavior problem.
                In worst case scenario user after updating Record in one part of application in second one can see ValuesManager with couple of DynamicForms when only one has new values and other ones has old values and it can lead to unexpected behavior of users.

                Because it's quite new functionality in my application I've got workaround to this problem on application level - flow of handlers called when user changes a record.
                But when we removed this workaround effects were quite messy so probably in other applications users can have really unexpected results.

                Best regards
                Mariusz Goch

                Comment


                  #9
                  Ooh. Thank you for clarifying. This has been bumped in priority.

                  Comment


                    #10
                    We've now made a change to address this issue.
                    Please try the next nightly build dated May 11 or above (Branches 13.0 and 13.1)

                    Regards
                    Isomorphic Software

                    Comment


                      #11
                      Hi,

                      Sorry for the delay.
                      I've run some tests and I confirm it's also fixed.
                      I've tested simple test case and also original scenario in full application and it looks fine.
                      Warnings are gone and most importantly data is updated in all forms of ValuesManager.

                      I will probably test this functionality way better soon because this made some of my solutions obsolete and I'm looking forward to clean up my code.

                      Best regards
                      Mariusz Goch

                      Comment


                        #12
                        Thanks for confirming the fix!

                        We love to hear about simplified code, as well :)

                        Comment

                        Working...
                        X