Announcement

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

    Is it possible to periodically refresh data?

    Hello,

    i would like to auto refresh data in a listgrid periodically.
    is it possible in smartgwt?

    many thanks

    xiaochen

    #2
    i think using timer could fulfill it.

    new Timer() {

    public void run() {
    // fetchdata and update the grid
    }
    }.scheduleRepeating(10);


    when i finish, i will post my solution.

    thanks

    Comment


      #3
      Does anyone know if there is a best practices way of doing this?

      A couple of our pages will have timeframes set on them like "since last week" and we would like for those to have the option to autorefresh so that new data that was written to the database by something outside of this page (a running service) will show up automaticially (you can picture this as a status screen that updates automaticially).

      I can set a timer like the example shown above, but it seemed like there may be a cleaner way. If that is the best way would we just call fetchData in the run method?

      Thank you in advance for any help on this.
      Patrick

      Comment


        #4
        At a high level you have two options here.
        One option is to push data from the server to the client in realtime. You may want to consider the optional SmartGWT Realtime Messaging module for this.
        Another option is polling - basically setting up some kind of looping timer on the client to periodically issue server requests to check for changes.

        Either way, once you are notified of a change, you can integrate it into your dataSource directly via DataSource.updateCaches(), or you can force cache invalidation.

        Comment


          #5
          Thank you for the info.

          I have the timer firing correctly.

          I have a case where I do not have to worry about my records changing, so calling invalidateCache() is more than I need. I just need to get new records when they show up in the datastore.

          The thing that is updating the database with new records is outside of my display so I cannot set an event for it.

          Is there a way I can get new records without having to call invalidateCache()?

          Comment


            #6
            Have your looping timer issue a custom fetch type request.
            Use DMI or some other mechanism to pick up only the changed records from the database and put them in the response.
            In the callback on the client - check for the response having any records in it. If there are any, call the 'updateCaches' API on the dataSource and pass in the changed or added records as data. This should cause the changes to show up in your application.

            If that doesn't get you going we must be misunderstanding your use case - probably best to lay out exactly what you're doing and why this approach doesn't work for you.

            Comment

            Working...
            X