Announcement

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

  • WARN:AutoTest:Locator with DynamicForm setReadOnlyWhen on Window

    Hi,
    I''ve found problems with setReadOnlyWhen() on an FormItem.

    First problem is that condition is not always applied when form is showed and second my console is filled with errors like:
    Code:
    *23:45:48.550:WARN:AutoTest:Locator string:item[0][Class="DynamicForm"] matching by index gave [DynamicForm ID:isc_DynamicForm_1]. Reliability cannot be guaranteed for matching by index if the underlying application undergoes any changes.
    Test case:
    Code:
    DataSource ds = new DataSource();
    ds.addField(new DataSourceTextField("type"));
    ds.addField(new DataSourceFloatField("discount"));
    
    DynamicForm form = new DynamicForm();
    form.setDataSource(ds);
    
    AdvancedCriteria criteriaCollect = new AdvancedCriteria();
    criteriaCollect.addCriteria("type", OperatorId.EQUALS, "collect");
    
    RadioGroupItem itemType = new RadioGroupItem("type");
    itemType.setValueMap("collect", "pay");
    itemType.setRedrawOnChange(true);
    itemType.setValue("collect");
    
    FloatItem itemDiscount = new FloatItem("discount");
    itemDiscount.setDecimalPad(2);
    itemDiscount.setValidateOnExit(true);
    itemDiscount.setRequired(true);
    itemDiscount.setReadOnlyWhen(criteriaCollect);
    itemDiscount.setReadOnlyDisplay(ReadOnlyDisplayAppearance.DISABLED);
    
    form.setFields(
            itemType,
            itemDiscount
    );
    
    Window window = new Window();
    window.setAutoCenter(true);
    window.setAutoSize(true);
    
    window.addItem(form);
    window.show();
    I've made it work at startup by adding DataSource and editNewRecord() / editRecord() to form.
    Code:
    Record r = new Record();
    r.setAttribute("type", "collect");
    form.editRecord(r);
    But I cannot resolve issue with warnings. They appear in large amount when I change radio value.
    Strange is that when I put this form on page (not in window) it works fine. It doesn't help to wrap form in other layouts and then into window.
    So problem is probably connected with Window.

    Tested on SmartGWT 12.0p 2019-04-11

    Best regards
    Mariusz Goch

  • #2
    Changes to address the issues you highlighted will be available in 12.0 and 12.1 builds starting April 18. The code provided will then work with or without the DataSource on the form and no call to editNewRecord is required. You shouldn't see any warnings in the logs either.

    Comment


    • #3
      Hi,
      Warnings are gone and datasource is no longer needed but when datasource is set there is now a problem with handlers.
      ChangedHandler is called on an item when form.setValue() is called but it should only be called when user change this value.
      It happens when both datasource is set and setReadOnlyWhen() criteria is set.
      Test case:
      Code:
      DataSource ds = new DataSource();
      ds.addField(new DataSourceFloatField("item1"));
      ds.addField(new DataSourceFloatField("item2"));
      
      DynamicForm form = new DynamicForm();
      form.setDataSource(ds);
      
      AdvancedCriteria criteria = new AdvancedCriteria();
      criteria.addCriteria("item1", OperatorId.LESS_THAN, "10");
      
      FloatItem item1 = new FloatItem("item1");
      item1.addChangedHandler(new ChangedHandler() {
      
          @Override
          public void onChanged(ChangedEvent event) {
              GWT.log("onChanged item1");
              form.setValue("item2", Random.nextDouble());
          }
      });
      
      FloatItem item2 = new FloatItem("item2");
      item2.setReadOnlyWhen(criteria);
      item2.setReadOnlyDisplay(ReadOnlyDisplayAppearance.STATIC);
      item2.addChangedHandler(new ChangedHandler() {
      
          @Override
          public void onChanged(ChangedEvent event) {
              GWT.log("onChanged item2");
          }
      });
      
      form.setFields(
              item1,
              item2
      );
      When you enter value in item1 and its larger then 10 onChange handler is being called on item2.
      It's quite dangerous because can lead to infinite loops and default behavior is that

      It's even stranger that in above example item2 changed handler is called twice when one digit is entered in item1.

      Comment


      • #4
        We are unable to reproduce the issue of the onChange handler firing for item2 in your test code as detailed. It does fire when the value is manually edited but not based on changes to item1.

        Comment


        • #5
          Sorry, one more thing.
          I've got my custom skin modifications loaded that set autocomplete to native.

          Corrected test case that shows problem on default Enterprise skin:
          Code:
          DataSource ds = new DataSource();
          ds.addField(new DataSourceFloatField("item1"));
          ds.addField(new DataSourceFloatField("item2"));
          
          DynamicForm form = new DynamicForm();
          form.setDataSource(ds);
          
          AdvancedCriteria criteria = new AdvancedCriteria();
          criteria.addCriteria("item1", OperatorId.LESS_THAN, "10");
          
          FloatItem item1 = new FloatItem("item1");
          item1.addChangedHandler(new ChangedHandler() {
          
              @Override
              public void onChanged(ChangedEvent event) {
                  GWT.log("onChanged item1");
                  form.setValue("item2", Random.nextDouble());
              }
          });
          
          FloatItem item2 = new FloatItem("item2");
          item2.setReadOnlyWhen(criteria);
          item2.setReadOnlyDisplay(ReadOnlyDisplayAppearance.STATIC);
          item2.setAutoComplete(AutoComplete.NATIVE);
          item2.addChangedHandler(new ChangedHandler() {
          
              @Override
              public void onChanged(ChangedEvent event) {
                  GWT.log("onChanged item2 !!!!!!!!!!!!!");
              }
          });
          
          form.setFields(
                  item1,
                  item2
          );
          So problem exists when all 3 conditions are met:
          1. Form has DataSource set
          2. setReadOnlyWhen is used
          3. AutoComplete is set to NATIVE on field that it's value is changed by form.setValue()


          Hope you can reproduce this problem now.
          Best regards.

          Comment


          • #6
            Open the Console. visit the screen in which you are experiencing the error. In Chrome, navigate to View > Developer > JavaScript Console or extra equipment > JavaScript Console or press Ctrl + Shift + J.
            discover the mistake. the mistake console will open. in case you do not see any errors try reloading the page.
            eztv.io proxy
            https://www.techtrickhub.com/alterna...e-and-popcorn/
            EZTV Proxy 2019 EZTV Unblocked & EZTV Mirror Sites List (100% Working) Updated List - EZTV Movie Torrents Proxies - How to access / Unblock EZTV

            Comment

            Working...
            X