Displaying data when it arrives


I’ve got a table which displays a (potentially) very large result set and the time for computing the result set can be big. OTOH, it is likely that some data arrives early. (Use case: Search for particular entries in a big application log file.)

Ideally, the table would show data as soon as it arrives and wait for more data and I could, for example, pick a particular log entry to open in a new tab.

Is that possible? Ideally without any asynchronous techniques? As I said, I am dealing with log files and I do not want to spend too much time on dealing with overly complex code like spawning (and, in particular, terminating!) external threads.




Two different strategies, as I see it, are the following:

  1. Implement a Container that can lazily fetch the information that is to be displayed. This is how the Table component works, and you can process a little bit at a time using this method
  2. Use a background thread that fills the container and the Refresher or ICEPush add-ons to refresh the browser while the thread is working.

It might also be possible to pre-process the logs outside of your application before implementing method #1. I would probably go for a combination of #1 and #2 if there is massive amounts of data involved, since everything you put in a container, referenced from somewhere in your application, will stay in the HTTP session.


Thanks for the reply. As I said, I do believe that Refresher or ICEPush are too complex for my purposes.

As for the lazy loading: I’d basically like to use that. However, from my understanding it is based on the fact that I know at least the number of items and their ID’s in advance, or am I wrong?

Actually you probably could grow the container gradually, so you wouldn’t necessary need to know the exact number of items. I haven’t tried this, but it should work.

You do need to be able to find the index of an item, the ID can be the same as the index.


How would I do that? By spawning a separate thread? In that case I’d need to poll for updates? Any examples for doing this?

You should be able to load more while processing the IndexedContainer.getIdByIndex() call which is made by Table when painting the rows. However, you must keep the container filled more than 2x the pagelength (often variable, can be retrieved from Table). Basically what will happen is that as you scroll down and getIdByIndex() is called causing the container to fill, say a pagelength, more. This will causes the size of the container to change, which will cause the scrollbar to “jump”, so be aware of that.

The logic for keeping the buffer filled just enough and updating on the fly won’t be very easy to do. And you’ll probably end up with a laggy experience when scrolling in the Table.

Note that this is just thinking out loud, since I haven’t tried any of this, but it should be possible.

I wouldn’t really recommend doing it like this over the background thread with some push/polling solution, as the logic for this most certainly will be easier to build and understand. At least for me :wink: