Announcement

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

    What does this log message mean?

    OK, you know me, here comes a somewhat vague question:

    I see this in the logs:

    *17:30:29.936:MUP2:WARN:Log:Attempt to call internalSetID to change id from isc_ResultSet_0 to isc_ResultSet_0 after the SC instance has already been created
    I am sure i haven't seen this before, but i'm not certain if this is because i've upgraded the smartgwt version (running 13.1-p20250205), or if it's one of my changes.

    I not sure how to interpret this warning, i'm not seeing how i could call that function, could you perhaps help me understand it better?

    cheers

    EDIT:
    turns out i found the reason. We have an issue where a searchfunction we've had for a grid doesn't work anymore, not sure why.

    Turns out that even if the grid has tons of records, the grid.getRecords() returns an empty array. I could have sworn that this used to work, i would suspect that it stopped working after we upgraded to 13 and missed it in testing. Anyway.

    I then instead tried getRecordList(), and that method does indeed return all records in the grid. However, calling that method results in the above warning being logged. Feels weird.

    EDIT2:
    Turns out, you get the same warning if you call grid.getResultSet().getAllRows(), which is the recommended way of getting all rows from a grid according to the Javadocs.

    Also, calling any of those methods results in the dataarrivedhandler getting called for some reason. (not happening with getRecords()) This is a datasource with cacheAllData set to true.
    Last edited by mathias; 19 Mar 2025, 09:18.

    #2
    Accessing data from a ResultSet can cause rows to be fetched, and even if no request actually leaves the browser (because the DataSource is cacheAllData:true) this still correctly results in DataArrived firing because from the perspective of the Grid/ResultSet, data has arrived, and the grid doesn't get to know that it came from within the browser.

    As far as the warning, this has to do with instantiation voodoo in SmartGWT (wouldn't happen in SmartClient). One wild guess would be: did you put an ID into listGrid.dataProperties as a means of being able to look up your ResultSet by that ID? That wouldn't actually be allowed, because ResultSets need to be dynamically created and re-created.

    Comment


      #3
      Hey thanks for quick response. Voodoo indeed! :)

      I must say i don't totally get the ondataarrived. The grid has 200 rows for example. That's all the data that exists, they are loaded in the grid, i can see them. I call grid.getresultset.getallrows() - ondataarrived is called. To me, makes no sense - no data has arrived, it's already there!

      (Not to mention that calling "getResultSet()", i.e. get the result of a data operation, triggers a data operation)


      No, i did not touch any dataproperties, resultset or anything. I didn't even know there was a resultset before i read in the javadocsthat you, rather than call getRecords() (as a complete noob like me would have guessed), actually call grid.getResultSet().getAllRows()...

      Here's the bottom line:

      I have a grid. it has data loaded (for a "cachealldata" datasource)
      I want to get the rows that are visibily loaded in the grid and iterate through them. Is there a way that i haven't tried that returns the rows and that doesn't trigger a log warning?

      Thanks again!

      Comment


        #4
        Right, well i've always found it confusing that setting a criteria or calling filterData on a grid means that "new data arrives", but i guess that's just me.

        Anyway, regarding that log warning, i made a stand-alone test case for you because i'm such a nice guy. As you can see, no shenanigans.

        Just run it, press the button that counts the rows in the grid, and you get that warning in the log.

        HOWEVER, i also want to elaborate on the getRecords() method. Please look at the code below.

        It's a simple listgrid with a button that counts the records.
        In my test datasource, i can control via a parameter how many records that exist. (using the "dsrecords" variable)

        Here's what i found:
        Up to 125 rows, both getRecords() and grid.getresultset.getAllRows return the same number. But above that, getRecords() is empty!

        That's peculiar to me. It shoudn't be the pagesize, that 75, no?
        In any case, it sure feels strange that it returns 0 depending on the amount of records. Any ideas?


        Code:
        import com.google.gwt.core.client.GWT;
        import com.smartgwt.client.data.Criteria;
        import com.smartgwt.client.data.DataSource;
        import com.smartgwt.client.data.fields.DataSourceTextField;
        import com.smartgwt.client.widgets.grid.ListGridRecord;
        import com.smartgwt.client.widgets.grid.ListGrid;
        import com.smartgwt.client.widgets.grid.ListGridField;
        import com.smartgwt.client.widgets.layout.HLayout;
        import com.smartgwt.client.widgets.IButton;
        import com.smartgwt.client.data.Record;
        import com.smartgwt.client.util.SC;
        
        public class Test extends HLayout {
        
            Criteria crit = null;
        
            public Test() {
                setWidth100().setHeight100();
                setPadding(15);
                setMembersMargin(10);
                DataSource ds = DSTestDS.getInstance();
                ListGrid listGrid = new ListGrid();
                listGrid.setDataSource(ds);
                listGrid.setAutoFetchData(true);
                listGrid.setWidth(400);
                ListGridField idField = new ListGridField("id", "ID");
                ListGridField nameField = new ListGridField("name", "Name");
                listGrid.setFields(idField, nameField);
                listGrid.addDataArrivedHandler(dataArrivedEvent -> GWT.log("DataArrivedHandler called;" + dataArrivedEvent.getEndRow()));
                addMember(listGrid);
        
                IButton button = new IButton("Count");
                button.addClickHandler(clickEvent -> {
                    SC.say("The grid has " + listGrid.getResultSet().getAllRows().length + " records according to 'listGrid.getResultSet().getAllRows()<br/><br/>" +
                        "The grid has " + listGrid.getRecords().length + " records according to 'listGrid.getRecords");
                });
                addMember(button);
        
                IButton button2 = new IButton("Add/Remove Crit");
                button2.addClickHandler(clickEvent -> {
                    if(crit == null){
                        crit = new Criteria();
                        crit.addCriteria("name", "Corp 12");
                        listGrid.setCriteria(crit);
                    }else{
                        crit = null;
                        listGrid.setCriteria(null);
                    }
                });
                addMember(button2);
            }
        
            private static class DSTestDS extends DataSource {
                private static DSTestDS instance = null;
                int dsrecords = 125;
        
                public static DSTestDS getInstance() {
                    if (instance == null) {
                        instance = new DSTestDS("localDSTestDS");
                        instance.setCacheAllData(true);
                    }
                    return instance;
                }
        
                public DSTestDS(String id) {
                    setID(id);
        
                    DataSourceTextField idField = new DataSourceTextField("id", "ID");
                    DataSourceTextField nameField = new DataSourceTextField("name", "Name");
                    setFields(idField, nameField);
        
                    setTestData(Test.getNewRecords(dsrecords));
                    setClientOnly(true);
                }
            }
        
            public static ListGridRecord createRecord(int id, String name) {
                ListGridRecord record = new ListGridRecord();
                record.setAttribute("id", id);
                record.setAttribute("name", name);
                return record;
            }
        
            public static ListGridRecord[] getNewRecords(int amount) {
                ListGridRecord[] records = new ListGridRecord[amount];
                for (int i = 0; i < amount; i++) {
                    records[i] = createRecord(i + 1, "Sci-Fi Corp " + (i + 1));
                }
                return records;
            }
        }

        Comment


          #5
          We'll be committing a fix to prevent the bogus error message you reported from being logged. As far as the other issue affecting getRecords(), that behavior is actually expected as documented here:

          If this is a DataBound grid this method will return an empty array unless the entire set of data for the current criteria has been loaded into the client, in which case all matching rows will be returned. For DataBound grids, you can call getResultSet() to retrieve the current data set as a ResultSet object.
          In your repro code, if dsrecords is set to 150, then indeed getRecords() will return an empty array until you force all rows to load by slowly scrolling down.

          Comment


            #6
            Hey thats great, any any idea when it'll be downloadable? i'll hold our release to get it in.

            Regarding the rows/getRecords():

            I had read that line, but i did not draw the conclusion from the docs that unless the rows are actually rendered, the grid won't have all data even though you have cachealldata in the datasource.

            So, if i want to get around it, i can call setDataPageSize() - but is there another way to say "i want all rows to be in there right away"? ShowAllRecords()? This whole thing isn't crystal clear to me.

            Comment


              #7
              See listGrid.dataFetchMode.

              Comment


                #8
                Originally posted by mathias View Post
                Hey thats great, any any idea when it'll be downloadable? i'll hold our release to get it in.
                We've now applied it to SGWT 13.1+. If you pick up a build dated 2025-03-22 or beyond, it should have the fix.

                Regarding the rows/getRecords():

                I had read that line, but i did not draw the conclusion from the docs that unless the rows are actually rendered, the grid won't have all data even though you have cachealldata in the datasource..
                The API you're calling looks at the grid's ResulSet (it's "data" property). So all records need not be rendered, but they do have to be in that ResultSet. Scrolling the grid is just one easy way to do that interactively.

                As the post above implies, you can immediately fetch all records by setting the grid's dataFetchMode to "local".

                Comment


                  #9
                  As far as dataArrived(), it appears to be functioning normally in your repro code. You get a notification, as expected, when new data arrives in your component's ResultSet. With the default length of 125, this only happens once, when the app is loaded. If you increase it to 200, then if you scroll down, it will fire again as additional rows are loaded from the DataSource.

                  We do see how the mention of "server" in the dataArrived() docs could cause confusion and will look at perhaps rephrasing that.

                  Comment

                  Working...
                  X