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.
A user adds a record to a table but not shown in B users table when a refre
Hi My code is as follows
I have a notes table and i want to update the table every 2 sceonds so that concurrent users can see the added notes for a specific object.
I have refresher which runs and it doesnt seem to be getting the updates. But when the refresh button is clicked I could see the added notes.
When User A adds a note, user A can see the added notes in the table. But User B cannot see, he simply has to click refresh to see the new notes added by A.
the code in the addnotespopover is this.
VaadinSession.getCurrent().lock();
NoteResponse noteResponse = (NoteResponse) response.getData();
Note newNote = (Note) noteResponse.getNote();
mainTable.getContainerDataSource().addItem(newNote);
mainTable.setSortContainerPropertyId("created");
mainTable.sort();
mainTable.refreshRowCache();
finally {
VaadinSession.getCurrent().unlock();
}
This is the method for the refresher
if (VaadinSession.getCurrent().getAttribute(FUser.class) != null) {
final Refresher refersher = new Refresher();
refersher.setRefreshInterval(applicationProperties.getNotesRefreshTime());
refersher.addListener(new RefreshListener() {
@Override
public void refresh(Refresher source) {
if (noteTable != null) {
notesTableLayout.removeComponent(notesPanel);
notesTableLayout.removeComponent(addNoteButton);
notesTableLayout.addComponent(buildNotesPanel());
notesTableLayout.addComponent(addNoteButton);
}
}
});
MobileUI.getApp().addExtension(refersher);
Can someone please advise me?
Have you enabled push (@Push annotation on UI class)?
And in your refresh method run code that performs UI changes in UI.access()
refersher.addListener(new RefreshListener() {
public void refresh(Refresher source) {
ui.access( new Runnable() {
public void run() {
if (noteTable != null) {
notesTableLayout.removeComponent(notesPanel);
notesTableLayout.removeComponent(addNoteButton);
notesTableLayout.addComponent(buildNotesPanel());
notesTableLayout.addComponent(addNoteButton);
}
}
})
}
})
By the way, I think you don't need to lock and unlock session when adding note.
Regards
Marco