How to fill new data into Table dynamically

Hello, guys!

I’m looking for right way to create a table that could upload new rows dynamically. As a DataSource I’m using SQLContainer with TableQuery. There could be much of data which should be uploaded quickly.

Anyway, my current realization is following: Table messagesList = new Table(); ............................... messagesList.setCacheRate(0.1d); messagesList.setContainerDataSource(messagesContainer);messagesList.setSelectable(true); messagesList.setImmediate(true); messagesList.setSizeFull(); new InitializerThread().start(); ...............................
Data is uploading using refreshRowCache method and Vaadin Push tecknology in another thread:

class InitializerThread extends Thread {
        @Override
        public void run() {
            while (!Thread.interrupted()) {
                try {
                    Thread.sleep(refreshMessagesPeriod);
                } catch (InterruptedException e) {
                }
                access(new Runnable() {
                    @Override
                    public void run() {
                        if (messagesList != null && !messagesList.getItemIds().isEmpty()) {
                            messagesList.refreshRowCache();
                            messagesList.focus();
                        }
                    }
                });
            }
        }

This approach has many disadvantages:

  1. If there are many rows in the table, it is very inefficient way to refresh all row’s cache in the table everytime.
  2. Scroll bar jumps to the top of page in the table when the row’s cache is refreshing. I didn’t find the way to save the scroll’s position and set the previous scroll position after refresh.
  3. If I select some text in a cell of the table, the selection dissapears after row’s cache refresh.

I believe that there is a lightweight and more nice technique to fill new data into Table dynamically.

p.s. I’m using Vaadin 7.1.15 and it is allowed to change version of Vaadin type of table (instead com.vaadin.ui.Table) if necessary.

I found better solution - control container content manually. Using IndexedContainer as a data source instead TableQuery and periodically checking a new data using sql queries. Vaadin Push helps me to visualise new rows. To prevent a scroll bar jump (which is the result of calling refreshRowCache) I call the private method Table.setCurrentPageFirstItemId(int, boolean) with following parameters: a new row ID, false (do not call refreshRowCache).