Multiuser work with the Vaadin table

With one table several operators are working, and always have to show up to date. I do this by clicking on the line -

...
table.addListener(new Table.ValueChangeListener() {
            public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {

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

}
});
...

But when I load -

table.setContainerDataSource(bic);

Selected line
is lost
.
What to do in this case? I would be grateful for the information!

Thank you!

This is because the Table clears its value when changing the container; there are no guarantees that the old value will still exist in the table. You can fix this by temporarily storing the value:

Object oldVal=table.getValue();
table.setContainerDataSource(newContainer);
table.setValue(oldVal);

Make sure that the class of oldVal has proper equals() and hashcode() implementations, otherwise the above won’t work.

Thanks for the answer, Thomas Mattsson! :smiley: