How to keep cursor on row when data is updated?

你说的曾经没有我的故事 提交于 2019-12-12 04:22:17

问题


The data in SPA should be updated periodically to show the current db state in the table. I'm trying to do it by the click event on a table row.

table.addListener(
    new Table.ValueChangeListener() {
        public void valueChange(final ValueChangeEvent event) {

            BeanItemContainer<Incoming> bic;
            Query query = sess.createQuery("...");
            List l = query ...
            bic = new BeanItemContainer<Incoming>(l);
            table.setContainerDataSource(bic);
        }
    }
);

But at this line the cursor is lost:

table.setContainerDataSource(bic);

How can I keep cursor on row when data is updated?


回答1:


With your current approach, I would do :

...
Object selection = table.getValue();
bic = new BeanItemContainer<Incoming>(l);
table.setContainerDataSource(bic);
table.setValue(selection);
...


来源:https://stackoverflow.com/questions/13043152/how-to-keep-cursor-on-row-when-data-is-updated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!