Announcement

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

    SelectItem sends to many requests on draw (with and without ProgressiveLoading)

    Hi Isomorphic,

    please see this v10.1p_2016-07-08-based testcase, where the two SelectItems send too many requests on draw:

    With ProgressiveLoading, it looks like this:

    Click image for larger version

Name:	WithPL.PNG
Views:	104
Size:	44.7 KB
ID:	239145


    Without ProgressiveLoading it looks like this:

    Click image for larger version

Name:	WithoutPL.PNG
Views:	78
Size:	30.4 KB
ID:	239146


    In both cases I'd expect not to see the red-marked requests. Please note the times sent of the requests. It seems that they are triggered after the previous requests was progressed on the client.
    Also the 1st request is for rows 0-78. I find this suspicious as well, as this used to be 75 and the requests afterwards are for 75 rows.

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
        private IButton recreateBtn2;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate with ProgressiveLoading");
            recreateBtn.setWidth(200);
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate(true);
                }
            });
    
            recreateBtn2 = new IButton("Recreate without ProgressiveLoading");
            recreateBtn2.setWidth(200);
            recreateBtn2.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate(false);
                }
            });
    
            mainLayout.addMembers(recreateBtn, recreateBtn2);
            mainLayout.draw();
        }
    
        private void recreate(boolean withProgressiveLoading) {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("Too many requests in either case" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            DynamicForm df = new DynamicForm();
            SelectItem employeeSI = new EmployeeSI("EmployeeId", withProgressiveLoading);
            SelectItem supplyItemSI = new SupplyItemSI("itemID", withProgressiveLoading);
    
            df.setFields(employeeSI, supplyItemSI);
    
            w.addItem(df);
            w.show();
        }
    
        private class ListGridFieldHidden extends ListGridField {
            public ListGridFieldHidden(String name) {
                super(name);
                setHidden(true);
            }
        }
    
        private class EmployeeSI extends SelectItem {
            public EmployeeSI(String name, boolean withProgressiveLoading) {
                super(name);
                setTitle("Employee");
                setOptionDataSource(DataSource.get("employees"));
                setValueField("EmployeeId");
                setDisplayField("Name");
                setSortField("Gender");
    
                setRequired(true);
                setValidateOnChange(true);
    
                ListGridField empname = new ListGridField("Name");
                ListGridFieldHidden EmployeeId = new ListGridFieldHidden("EmployeeId");
                ListGridFieldHidden EmployeeType = new ListGridFieldHidden("EmployeeType");
                ListGridFieldHidden Gender = new ListGridFieldHidden("Gender");
    
                setPickListFields(EmployeeId, empname, EmployeeType, Gender);
    
                if (withProgressiveLoading) {
                    ListGrid plp = new ListGrid();
                    plp.setProgressiveLoading(true);
                    setPickListProperties(plp);
                }
            }
        }
    
        private class SupplyItemSI extends SelectItem {
            public SupplyItemSI(String name, boolean withProgressiveLoading) {
                super(name);
                setTitle("SupplyItem");
                setOptionDataSource(DataSource.get("supplyItem"));
                setValueField("itemID");
                setDisplayField("itemName");
                setSortField("category");
    
                setRequired(true);
                setValidateOnChange(true);
    
                ListGridField itemName = new ListGridField("itemName");
                ListGridFieldHidden itemID = new ListGridFieldHidden("itemID");
                ListGridFieldHidden sku = new ListGridFieldHidden("SKU");
                ListGridFieldHidden category = new ListGridFieldHidden("category");
    
                setPickListFields(itemID, itemName, sku, category);
    
                if (withProgressiveLoading) {
                    ListGrid plp = new ListGrid();
                    plp.setProgressiveLoading(true);
                    setPickListProperties(plp);
                }
            }
        }
    }
    Best regards
    Blama

    #2
    Hi Isomorphic,

    not super important, but did you already look into this one?

    Best regards
    Blama

    Comment


      #3
      Yes, we've had a look - the initial investigation indictaes that the reason for the two fetches on your Employees-bound picker is that a fetch is issued on item.drawn() , and item's form is being drawn multiple times, as a result of not being autoDraw:false and being added to a layout/window. What's mysterious is that this does not occur with the other item in your test (and nor with the first item, with other dataSources).

      Also, the issue with selecting 79 rows instead of 75 is SmartGWT only - it doesn't happen in SmartClient.

      We'll look deeper into thte matter with these details to work from and update here when a fix is in place, for all three issues (double fetch, progressive fetches, wrong requested row-count).

      Comment


        #4
        Hi Isomorphic,

        FYI, perhaps important: I just retested - I did not and do not see a double fetch.
        In the 1st screenshot the queued requests go to different DataSources, so this is OK, if that is what you mean.

        Where do you see a 2nd fetch for the same data?

        Best regards
        Blama

        Comment


          #5
          The second image in your original post (without progressiveLoading) shows three requests being issued, two in a queue (for different DS's, correctly) and then a third, to the same DS as the first one.

          Not two fetches *for the same data* - just two fetches on the same DS.

          Comment


            #6
            By way of a follow-up - in all cases here where you see unexpected fetches, the reason is that the total number of cells to be drawn is less than drawAllMaxCells, the default for which is 250 - see the doc for that attribute.

            Both SelectItems specify only 1 *visible* pickListField:

            1) the Employees table has only 100 or so rows, so a second fetch is issued for the remaining rows beyond the initial page-size

            2) supplyItem has many rows, but progressiveLoading works by setting a totalRows just higher than the current cache-size - hence, you get a number of fetches until the local cache exceeds drawAllMaxCells

            An upcoming internal discussion may result in changes being made in this area - but you should be able to address all the issues reported here by just setting drawAllMaxCells to zero (or any number below your page-size) via pickListProperties.
            Last edited by Isomorphic; 11 Aug 2016, 21:44.

            Comment


              #7
              Hi Isomorphic,

              creating this testcase I remembered this post and retested #1 from this thread, now using v11.1p_2018-01-18.
              The result did not change a lot. There is one request less for supplyItem when using progressiveLoading. This is consistent with your 2) in #6. The supplyItem requests are 0-97, 98-173, 174-249, so the 250-drawAllMaxCells-threshold is reached with one request less.

              What's more interesting is, that using the testcase from the linked post (which is using normal no-progressiveLoading SelectItems as ListGridField-editor), those extra requests do not happen at all.
              I assume this due to the fact that you use a different drawAllMaxCells-value for the generated SelectItems.

              I don't know if this assumption is correct or if this thread here is important (it's not to me), but I wanted to let you know the findings, in case you find this interesting.

              Best regards
              Blama

              Comment

              Working...
              X