Announcement

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

    ResultSet.allMatchingRowsCached

    We are currently using 3.0p dated March 19, 2013.
    I have an issue where ResultSet.dataChanged is fired due to DataSource.updateCaches being called to insert a new record into the cache. The Handler is coded as such:

    Code:
     public void onDataChanged(DataChangedEvent event) {
    if(resultSet.allMatchingRowsCached()) {
    //update interface
    } else {
    resultSet.getRange(0, length);
    }
    I would expect allMatchingRowsCached to return true since the server side fetch occurred prior to this add, however it returns false. This causes the code to attempt a server fetch. However, the subsequent call to getRange does not result in a server fetch.

    Am I misusing the API here? At one point this code worked as I expected, but it appears something has changed.

    This leads me to another question. What is the appropriate way to determine what record/s has changed in the cache? At present I just clear all data associated with the result set, and redraw everything. This is clearly inefficient and would like to optimize this behavior. At the point where DataSource.updateCaches is invoked I could implement some form of event to explicitly broadcast what changes have occured to the cache, but before I do I am wondering if I am missing something in your API that provides this feedback already. It does not appear that a ListGrid for example completely redraws when a record is added/updated/removed via the DataSource.updateCaches mechanism?

    #2
    If you've issued a fetch but the server has not yet responded, allMatchingRowsCached() would be expected to be false. You can check for this condition with resultSet.lengthIsKnown().

    You could add a DataSource.transformResponse() handler if you want to get more specific about what exact records have been updated or added.

    However, how did you get into this situation in the first place? Why are you trying to update that isn't automatically updated?

    Comment


      #3
      A fetch was issued, and the server has responded. I actually get the behavior I expect by just calling lengthIsKnown().

      I will take a look at transformResponse(), we have developed some custom data bound components. Namely our flash implementation of a Gantt chart, a Google Earth display, and a flash implementation for line charts.

      Comment


        #4
        From reading the documentation, I am not sure I am following how transformResponse is going to expose any more information to me when ResultSet.dataChanged is fired. The biggest issue I am encountering is that the DataChangedEvent contains no information as to what has changed. I am using DataSources to bind these objects to our data as we already have DataSources in place, and we use your realtime messaging to provide server push of ds changes from the server or other client actions.

        The aforementioned Google Earth piece is actually bound to three datasources, and I have found ResultSet to be a great way to maintain a view of the db. I was just wondering if you had a precanned hook to more detailed information about what caused dataChanged to fire in the first place. Or if I need to implement one on my own.

        Comment


          #5
          In transformResponse, you have access to the operationType and data, so that's everything we know.

          Maybe you think we're suggesting that you *call* transformResponse? No, we're suggesting that you *add a handler* for transformResponse.

          Comment


            #6
            I also have access to all of that information at the point in the code where DataSource.updateCaches is called from the realtime message providing the change. I was just curious if you already had something in place for easily identifying the changes that have occurred at the point where dataChanged is triggered. ie, The realtime message may indicate an update, which actually caused the criteria on the result set to remove the record from the cache.

            I will likely just remove the dataChangedHandler, and implement a custom GWT Event and Handler that I can fire.

            Comment


              #7
              Yes, for an update you issue from updateCaches(), you would have that information. transformResponse() would give you similar information for things like automatically issued saves from databound components.

              It's not clear what additional information you want - current rowNum of the record that was just updated or added? That you could get by using findIndex() to locate the record by primaryKey (which would also tell you if it was now missing form cache if you need to do that). It's unclear how implementing a custom event could increase the available information, but findIndex() would.

              Comment

              Working...
              X