How do I know when a table row has been updated?

I have a data package for reading and writing to my database. It can return Beans, so I used DataBeanContainer as my datasource.

When I call commit on a form, it updates the table, but I would like to have the table update the database since that is the central point for the data. That way, no matter what updates the table, the table will call tell me in code that an update occurred and I can then pass the bean to my data classes to update the database.

I looked but can not find where the table can tell me that the row data was changed. It can tell me that the selection changed, but not the data itself.

Does anyone know how to do this? Thanks in advance.

I don’t seriously know, since I’ve never been that concerned with databases and models, but if I recall correctly, Vaadin Containers/data model should provide you with item/property change listeners.

Not sure by DataBeanContainer if you meant BeanItemContainer, but we save our beans from the Form itself. That is, when the user clicks a Save button, we do data validations, and if all is okay, we call Form.commit(), which copies the form data back to our data source bean (via a series of setXXXX() calls), then we call a ‘save’ method on our bean that does whatever it needs to do (in our case, it saves the data via JDBC, but the mechanism to save is up to you). The save has to decide if it’s an update to an existing bean or saving a newly created bean. It also handles removing a bean (delete), and canceling an edit, in which case it calls Form.discard() to ensure those changes are put back to the bean.

Once that is done, we then update our container. We don’t update the Table directly as the Table will automatically be updated when the container is modified. Hope that helps even if it may not be the model you were attempting to follow.

Each table row is in fact a vaadin Item with a set of vaadin properties. When you have a bean item. each vaadin property is in a one-to-one mapping with a java field. A change to the property through the table will trigger a call to the setter in your bean. So you are already being notified…

Thanks for the help. What all this means is that the table does not know if the row changed. I could have the form save the data, but that would not work for table saves. I was looking for a single point for saves when dealing with table data, since I will have both form and table editing in my application.

I am aware that the bean is notified that something changes, but I did not want to have to put a call in every setter method to tell the bean that it changed. That seemed inefficient. If that is what I have to do, then that is what I will do.

Thanks again.