Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
TreeTable setValue not reprinting
I have a tree table which I am trying to update from a multi-threaded application.
I have tried various methods of updating an embedded image in row of a treetable. The results are completely inconsistent. Sometimes the table is updated and repaint is called and sometimes not. am I doing something wrong?
public synchronized void setState(int state) {
// Look at the value before the change
System.out.println("before:" + reportFileBean.getStateIcon().getSource().toString());
Item tempItem = reconciliationsTable.getItem(reportFileBean);
tempItem.getItemPropertyIds();
Property prop = tempItem.getItemProperty(SmartConstant.REC_TABLE_STATE);
Embedded image = (Embedded) prop.getValue();
image.setSource(new ThemeResource(TRAFFICLIGHTSSTRING[state]));
// look at the value after the change
System.out.println("after:" + reportFileBean.getStateIcon().getSource().toString());
reconciliationsTable.requestRepaint();
reconciliationsTable.requestRepaintAll();
reconciliationsTable.requestRepaintRequests();
reconciliationsTable.refreshRowCache();
reconciliationsTable.commit();
PropertySetChangeEvent event = new PropertySetChangeEvent() {
public Container getContainer() {
return reconciliationsTable.getContainerDataSource();
}
};
reconciliationsTable.containerPropertySetChange(event);
}
The value is always shown as changed in the system.out lines but not in my browser(chrome)
Thanks in advance for any help.
This happens because the browser only asks the server if anything has changed when you are doing something through the browser. In this case, where the changes are made from a different thread running on the server, there is no direct way for the browser to know about the changes.
You can however use one of the several polling or pushing add-ons available, see https://vaadin.com/web/matti/blog/-/blogs/to-push-or-dontpush for a thorough explanation of the concept.
Many thanks Leif,
Very clear explanation. I am considering using the refresher plugin to resolve this. Does that sound like it will solve the issue?
Yes, Refresher should work very nicely for the case you described.
The other solutions come with some additional benefits, but they also add a substantial amount of complexity.