Announcement

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

    TileGrid reload all data after invalidateCache

    hi, I am trying the smartgwtee 2.4 with gwt 2.1.1,
    and the problem exist when I use smartgwtee 2.2 and gwt2.0.x.

    I use TileGrid to load about 20k+ images from a Hibernate
    DataSource, and it works fine at the first load, only fetch
    the first 75 records from remote server.

    The content of my TileGrid will changed by other user, so
    I want to refresh the TileGrid by calling invalidateCache,
    then the TileGrid try to load all data after I call fetchData
    again.

    I search the forum, and didn't find the answer. But at the issue
    http://code.google.com/p/smartgwt/issues/detail?id=479
    I found the last comment is the same problem like mine:
    Code:
    Comment 5 by mehul8...@gmail.com, Sep 22, 2010
    Hello sanjiv,
    
    I face the problem to manually update tilegrid datasource
    
    actually invalidatecache() method continously sending query until all record fetch.
    
    If there is any alternate to invalidatecache please let me know 
    
    Thanking you.
    Would any one help me? Thanks very much.

    #2
    To get help, first create a minimal standalone test case that demonstrates the problem.

    Comment


      #3
      I reuse the showcase to demonstrate the problem.

      First of all, I create the datas in animals table:

      Code:
      for /L %x in (1,1,10000) do echo INSERT INTO animals (PICTURE,INFORMATION,COMMONNAME,LIFESPAN,SCIENTIFICNAME,DIET,STATUS) VALUES ('Alligator.jpg','In the 16th century, Spanish explorers in what is now Florida encountered a large formidable animal which they called "el largo" meaning "the lizard". The name "el largo" gradually became pronounced "alligator".','Alligator (American)',50,'%x','Carnivore','Not Endangered'); >> sql
      then execute the sql on the showcase's hsql database, it has 10027 rows now.

      Then, change the code, RecategorizeTile.java, comment the row:
      // leftGrid.setShowAllRecords(true)
      save the file, start the showcase server by "ant hosted"

      access the url by ie8:

      http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997#recategorize_tile

      just click the left selectitem, change it from "Endangered" to
      "Not Endangered", then you will see it try to fetch all data from
      the database.

      Comment


        #4
        At the developer console, I set the ResultSet, TileGrid, TileLayout's
        level to debug, then collect the logs when I change the animal's kind
        to "Not Endangered":

        15:46:49.831:MUP2:DEBUG:TileGrid:isc_TileGrid_0:Setting filter to: {
        "status":"Not Endangered"
        }
        15:46:49.847:MUP2:INFO:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):setCriteria: filter criteria changed, invalidating cache
        15:46:49.862:MUP2:INFO:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):Invalidating cache
        15:46:49.862:MUP2:DEBUG:TileGrid:isc_TileGrid_0:dataChanged: returning due to no data yet
        15:46:49.878:MUP2:DEBUG:TileGrid:isc_TileGrid_0:dataChanged: returning due to no data yet
        15:46:49.878:MUP2:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):getRange(0,1), cache check: 0,37 firstMissingRow: 0 lastMissingRow: 37
        15:46:49.893:MUP2:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):getRange: guessing forward scrolling
        15:46:49.893:MUP2:INFO:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):getRange(0, 1) will fetch from 0 to 75
        15:46:49.893:MUP2:INFO:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):fetching rows 0,75 from server
        15:46:50.049:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):Received 75 records from server
        15:46:50.049:XRP7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):full length set to: 1250
        15:46:50.065:XRP7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):integrating 75 rows into cache at position 0
        15:46:50.065:XRP7:INFO:ResultSet:isc_ResultSet_0 (created by: isc_TileGrid_0):cached 75 rows, from 0 to 75 (1250 total rows, 75 cached)
        15:46:50.081:XRP7:DEBUG:TileGrid:isc_TileGrid_0:filter or sort, new data same or longer
        15:46:50.283:TMR9:DEBUG:TileLayout:isc_TileGrid_0:starting $583()
        15:46:50.283:TMR9:DEBUG:TileLayout:isc_TileGrid_0:starting fit layout:true
        15:46:50.283:TMR9:DEBUG:TileLayout:isc_TileGrid_0:fit layout, using incremental rendering
        ...
        Last edited by SimonLei; 21 Jan 2011, 06:28.

        Comment


          #5
          I wonder why the refresh will try to reload all the records.
          So I enable ie8's script debug, set the breakpoint at the getRange method.
          When I see the call stack, I found the getRange's called from getTileRecord,
          which defined at line 3278 in ISC_Grid.js, I beautified it as:

          Code:
          ,isc.A.getTileRecord=function isc_TileGrid_getTileRecord(_1){
              var _2=this;var _3=_2.data;var _4,_5;
              if(isc.isA.ResultSet(this.data)&&!this.data.lengthIsKnown())
                  return null;
          
              if(this.showAllRecords
                  || !_2.getDrawnStartIndex() 
                  ||!_2.getDrawnEndIndex())
                  {
                      _4=0;_5=_3.getLength()
                  } else {
                      _4=_2.getDrawnStartIndex();
                      _5=_2.getDrawnEndIndex()+1;
                      if(_5>_3.getLength())_5=_3.getLength()
                  }
          ...
          When the first time the TileGrid is loaded, the
          this.data.lengthIsKnown() return false, so it just return
          without the other code called.

          When I try to refresh the TileGrid, the this.data.lengthIsKnown() is true,
          and the _2.getDrawnStartIndex() is 0, so !_2.getDrawnStartIndex() is true,
          it will set _4=0,and _5=_3.getLength(), which means load all the data.

          So I change the
          !_2.getDrawnStartIndex()
          to
          _2.getDrawnStartIndex() === undefined

          and solve the problem, it will only fetch the first 75 records now. :D

          Comment


            #6
            Thanks for the info Simon. This fix has been integrated into the framework and should be available in future nightly builds and official releases.

            Comment

            Working...
            X