Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I force Vaadin v8 to update the screen?

Tags:

java

vaadin

I have a small Vaadin v8 application that has several input fields (comboboxes, selectgroups, etc...). The content of most of these is determined by the chosen content of the first ComboBox. However, when I select something in it, all the others stay blank until I click one, at which point they all update. This is not desired behaviour, but I assume it's being caused by the server-side being up to date but not updating the client side view. (Even when adding requestRepaint() in my first Combobox's ValueChangeListener)

There must be some method to force Vaadin to get the data I want it to display even if no other components are clicked?

EDIT I'm not allowed to post answers to my own question so soon, so I'm putting it here temporarily:

I found that there's a javascript method that synchs client and server.

myComponent.getApplication().getMainWindow().executeJavaScript("javascript:vaadin.forceSync();");

The only problem I have now is that the ValueChangeListener on one of my comboboxes still only fires when I click another combobox (or the same one twice). It's the weirdest thing because the second combobox, when loaded, fires it's event perfectly.

like image 785
Valyrion Avatar asked Sep 30 '11 08:09

Valyrion


2 Answers

Is the first ComboBox in "immediate" mode?

If not, it probably should be : component.setImmediate(true).

See https://vaadin.com/book/-/page/components.selection.html

like image 89
Charles Anthony Avatar answered Sep 28 '22 02:09

Charles Anthony


I had the same problem, see below how it could be done in version 8.0.5 (from 2017):

@Push
public class WebUi extends UI {
   public void fireComponentUpdated() {
      getUI().push();
   }
}
like image 23
Thomas Avatar answered Sep 28 '22 03:09

Thomas