Update Table content by clicking on a button


My screen is composed of two tables.
I drag elements from a table to another. In the second table, there is an editable field to define the amount and a not editable field “result” which has as purpose to display a calculated amount.

Below the tables, there is a button which allow to calculate the “result”.

Both tables are filled thanks to BeanItemContainer.
Both tables have “setImmediate(true)”.

When I click on my button, I call a java method which retrieves all the items of the BeanItemContainer and, for each of them, calculate the result and set it in the item.
However, the client is not refreshed and I do not see the result.

But, if I drag and drop another item, the result of the calculation is correctly displayed.

How could I force the refresh of the elements of the table after the calculation of the result ?

I already tried myComponent.getApplication().getMainWindow().executeJavaScript("javascript:vaadin.forceSync();"); , but it is not working.

I had a look on the “Refresher” and “DontPull” components but it is not what I need.



No need to call javascript or something like that.

Could you show your code where you update te table?

My code is very basic :

Button calculateButton = new Button("Calculate");
        calculateButton.addListener(new Button.ClickListener() {
			public void buttonClick(ClickEvent event) {

The “model” variable is used to fill my form.

When I click on “Calculate”, the “model” is correctly updated.
But, no “signal” is sent to the client in order to refresh the values displayed on screen.

Do you have any idea ?



What data type is “model”?

I had a similar problem and fixed it like that:

 public void updateTableContent(Collection<?> entries) {
        Container containerDataSource = table.getContainerDataSource();
        for (Object entry : entries) {

In your case you must add the model-entries to the containerDataSource.

Maybe this helps.

The “model” is only a class used through a wizard to collect all the data entered in the different steps.
One of the attributes of the model is the collection of items, datasource of my table.

In my method, I loop in the collection in order to realize a calculation and fill one of the properties of the items.
So, the datasource is correctly modified, but the table is not refreshed automatically.
The only way I’ve found to solve the problem is to remove the table from the layout and to rebuild it …

But, I assume it is not the most beautiful solution…

Well, like I wrote above, you could remove the containerDataSource and re-add the entries, so you don’t have to rebuild the table.

Maybe a table.requestRepaint() could also help.

The table need to be warned that the data has changed.

Some container do it automatically, some containers do it if you use the container itself to update the underlying data, but for the others, you will need to manually “tell” it the data has changed.

If I remember well (but it is foggy up there today), the bean container has no way of knowing the beans have changed if they were not updated using the container interface. So you may want to try to change your computeAllocationSwitchUnits to work on the container and not the beans directly if possible.

Sometimes this is enough :


Sometime you will need to recreate the whole datasource as Marcel described.

Finally you may have the table not updating if computeAllocationSwitchUnits is doing some background processing (Thread, …), in that case check
this sticky


Thanks to both of you.

I have a last question :
Which does cost less ?

  • Rebuild the datasource or
  • Rebuild the table


Setting the data source for a table is probably the cheapest option.

Rebuilding the Table component could be expensive on the UI side (depending on what you mean by this), and rebuilding the container without detaching it from the Table and then reattaching it can be costly because of many notifications of changes from the container to the table.

Then again, all these are quite big operations, so some other, less expensive tricks to force some updates might apply if you cannot update the data via Vaadin data model APIs.