Announcement

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

    How to force a refetch

    How to force a refetch , for example in a tileGrid?
    I need to refetch some data and get inside the DSCallback.

    If I use invalidateCache(), I get indeed a refetch but I am not getting inside the DSCallback. This happens when an update on the same data occurs, so I guess it is related to cache.
    So I have this:
    Code:
    tileGrid.fetchData(new AdvancedCriteria(OperatorId.AND, c), new DSCallback() {
    
                                    @Override
                                    public void execute(DSResponse dsResponse,
                                            Object data, DSRequest dsRequest) {
                                        // I am never getting here
                                    }
    The fetch is done (because of the update!!!) but I am not getting inside the method.

    The only way to get inside is setting some criteria that are always different, e.g. a timestamp:
    Code:
    new Criterion("timestamp", OperatorId.EQUALS, new Date())
    This works and now I am getting inside the method. But I am getting two refetches now:
    the original
    my fetchData

    What is the correct way to deal this?

    I remember that some time ago you explained me that some fetches are ignored if they have the same criteria, so if I send two equal requests (together) , only 1 of these is being executed.
    So I guess this has to do with this behavior.

    Is there any DSCallback for the automatic refetches? If yes, I could put my method there.

    #2
    The timestamp workaround seems not to always work.
    The method only enters the DSCallback the first 2 times. After that, the fetch occurs and, again, the code is not entering the DSCallback

    Comment


      #3
      The DataArrived event is a good way to get a notification whenever data arrives, whether from initial fetch or because you called invalidateCache().

      Comment


        #4
        Using the DataArrivedEvent, I have a question: is the listGrid already populated when this method is being called?
        i..e. can I modify the data in the listGrid, for example getting a record of the listGrid and then changing its text? Or selecting the record depending on some criteria?

        Comment


          #5
          Yes, DataArrived is the appropriate time to do things like that.

          Comment


            #6
            ok, thank you, I will change some code for this.
            Until now, I was using listGrid.fetchData() and inside the DSCallback I was doing those things. As I read in your other answers this is not correct, since the DSCallback only gets a copy of the data.
            So what is the correct use of the DSCallback in the ListGrid fetch method? What valid things can be done here ?

            Comment


              #7
              It's valid to access the ListGrid data when the callback fires. It's just not valid to assume the data passed to you in the callback is the exact same set of objects that have been populated into listGrid.data. If you want to modify listGrid.data, access ListGrid.data; don't assume other sets of objects are the same thing, as various caching settings can cause them to be different objects or the same objects.

              Note also that the docs for listGrid.fetchData() explain the circumstances when your callback will be called (you seemed confused about this in earlier posts in this thread).

              Comment

              Working...
              X