Table not updating after container update

Hi, I have an application that uses a split panel table/form to add and update data from a database. I was using the JPA criteria container, then switched to a simple custom container that used Spring Roo-enhanced entities.

The issue is the following, after adding an entity with the form the table does not reflect that new addition. I assumed that it might be the criteria container (propmpting the switch) or an issue with the data not making it to the database.

I verified that in both cases the data both makes it to the database and the collection of objects returned reflects the new addition. However the table never updates. Making it more interesting is the fact that one of my table columns has an embedded tree. Updating the list of items in tree with the form, seems to work just fine.

With my custom container, I added a naive implementation that just clears the container,executes a roo Finder, then does an addAll. I’ve verified that the returned data reflects the new field, but table that ‘owns’ the container never manages to display the new row.

Any ideas?

It is unclear to me if you are using the Vaadin Roo addon or not to create your UI starting point, and if so, which version.

In any case, the container of the table needs to be notified of any changes you make on the form and forward the notifications to the table. If you simply make the update to the database directly using the Roo entity methods like merge(), the container never gets told something has changed.

The easiest option for updates is to use an item from the table as the data source of the form. If you make any modifications by hand bypassing the form, do it through the item properties instead of directly on the entity (Form does this automatically). This way, notifications should be handled automatically.

For adding items, it too should be done via the container. How exactly it is done depends on the container, but most containers do provide some addItem() API. Some containers simply take a pre-constructed bean/entity instance (e.g. from a BeanItem used behind the Form) whereas others take a different approach such as requiring you to first create an empty item with the container, use it on the Form and then call some container method to save it.

If not making the updates directly via the container of the table, you will need to inform the container somehow of the change, or rebuild it. How to do this depends on the container used.