Announcement

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

  • #16
    Is "$H" in criteria reproducible using my test?
    Should I create a new topic for it?
    Thanks,
    MichalG

    Comment


    • #17
      We see the $H in certain situations, such as with Chrome browser, and to that end, the sample is useful. We are looking into why the $H is there.

      However, even without the $H, which we see using Firefox, your sample doesn't work. The server doesn't recognize the request and returns an error. Can you provide us with a working sample? Perhaps you need to set the RestDataSource's dataURL. Have you made any other customizations that you haven't mentioned?

      Comment


      • #18
        The main trouble for me is that once "$H" occurs in the grid's criteria then grid is no longer updating its contents on data arrived - no matter if a record is added via updateCaches() or by DataSource.addData().

        Code:
        package pl.com.tech4.client;
        
        import com.google.gwt.core.client.EntryPoint;
        import com.smartgwt.client.data.AdvancedCriteria;
        import com.smartgwt.client.data.DataSourceField;
        import com.smartgwt.client.data.OperationBinding;
        import com.smartgwt.client.data.Record;
        import com.smartgwt.client.data.RestDataSource;
        import com.smartgwt.client.data.fields.DataSourceTextField;
        import com.smartgwt.client.types.DSDataFormat;
        import com.smartgwt.client.types.DSOperationType;
        import com.smartgwt.client.types.DSProtocol;
        import com.smartgwt.client.types.FieldType;
        import com.smartgwt.client.types.OperatorId;
        import com.smartgwt.client.util.JSON;
        import com.smartgwt.client.util.SC;
        import com.smartgwt.client.widgets.form.FilterBuilder;
        import com.smartgwt.client.widgets.grid.ListGrid;
        import com.smartgwt.client.widgets.layout.VLayout;
        
        public class MainEntryPoint implements EntryPoint {
        
            public void onModuleLoad() {
        
                layout();
                SC.showConsole();
            }
        
            private void layout() {
        
                RestDataSource projectDS = new RestDataSource();
                OperationBinding fetchBinding = new OperationBinding();
                fetchBinding.setOperationType(DSOperationType.FETCH);
                fetchBinding.setDataFormat(DSDataFormat.XML);
                fetchBinding.setDataProtocol(DSProtocol.POSTXML);
                projectDS.setOperationBindings(fetchBinding);
                projectDS.setDataURL("Project.xml");
                projectDS.setClientOnly(true);
        
                DataSourceField idField = new DataSourceField();
                idField.setType(FieldType.SEQUENCE);
                idField.setName("id");
                idField.setPrimaryKey(true);
                idField.setHidden(true);
                DataSourceTextField codeField = new DataSourceTextField();
                codeField.setName("code");
                DataSourceTextField managerField = new DataSourceTextField();
                managerField.setName("manager_code");
                managerField.setCanEdit(false);
                managerField.setValueXPath("manager/code");
        
                projectDS.setFields(idField, codeField, managerField);
        
                FilterBuilder fb = new FilterBuilder();
                fb.setDataSource(projectDS);
                AdvancedCriteria criteria = new AdvancedCriteria();
                criteria.addCriteria("manager_code", OperatorId.ICONTAINS, "B");
                fb.setCriteria(criteria);
        
                ListGrid lg = new ListGrid();
                lg.setAutoFetchData(false);
                lg.setShowFilterEditor(true);
                lg.setDataSource(projectDS);
        
                VLayout main = new VLayout();
                main.setHeight100();
                main.setWidth100();
                main.addMembers(fb, lg);
                main.draw();
        
                lg.filterData(fb.getCriteria());
                SC.logWarn(JSON.encode(lg.getCriteria().getJsObj()));
        
                Record record = new Record();
                record.setAttribute("id", 99999);
                record.setAttribute("code", "r/16/2");
                record.setAttribute("manager_code", "Black");
                projectDS.addData(record);
            }
        }
        Project.xml to run avove example:


        Code:
        <response>
            <requestId>Project_request5</requestId>
            <startRow>0</startRow>
            <endRow>1</endRow>
            <totalRows>2</totalRows>
            <data>
            <Project>
                <id>34872</id>
                <code>r/16</code>
                <description>fixing</description>
                <validFrom>2016-04-10T12:00:00Z</validFrom>
                <validTo>2016-10-07T12:00:00Z</validTo>
                <manager>
                    <id>1</id>
                    <code>Smith</code>
                </manager>
            </Project>
            <Project>
                <id>36548</id>
                <code>r/16/1</code>
                <description>testing</description>
                <validFrom>2016-04-27T12:00:00Z</validFrom>
                <validTo>2016-05-27T12:00:00Z</validTo>
                <manager>
                    <id>2</id>
                    <code>Brown</code>
                </manager>
            </Project>
            </data>
            <requestedDataSource>Project</requestedDataSource>
            <status>STATUS_SUCCESS</status>
        </response>

        Unfortunately, I am not able to replicate data cache problem in the sample - it hits me in the application though.

        So far I am using this ugly patch to remove "$H" from criteria on Chrome:

        Code:
            public native void removeDollarHFromCriteria() /*-{
                var prop = "$H";
                var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
                if (self.data && self.data.getCriteria) {
                    var crit = self.data.getCriteria();
                    delete crit[prop];
                }
            }-*/;
        If applied after lg.filterData() then grid updates its contents with no problem.

        Thanks,

        MichalG

        Comment


        • #19
          The $H arises from GWT's own internal logic, which caches the result of Object.hashcode() on a JavaScriptObject. We've made a change back to SGWT 5.1p that should prevent that property from interfering with the Framework. It will be in the nightly builds dated 2019-03-28 and beyond. Let us know if that resolves the issue.

          Comment


          • #20
            I have just verified that "$H" no longer exist in grid's criteria both in example and my app. Moreover, it also solved my app problem with dataArrived record not being shown in grid.
            Tested in SmartClient Version: SNAPSHOT_v12.1d_2019-03-28/LGPL Development Only (built 2019-03-28).

            I greatly appreciate you.
            MichalG

            Comment


            • #21
              We're happy the fix is working for you, but although the $H is now gone we still have not been able to reproduce any problems with your most recent sample when we disable the fix. The grid's ResultSet still seems to be updated as expected by your DS.addData() call.

              We'd really like to get a test case for this issue, as down the road, GWT or other third-party libraries might inject extra properties like this and break things again.
              Last edited by Isomorphic; 7th Apr 2019, 14:06.

              Comment

              Working...
              X