I am starting out with Vaadin (6.6.3, JPA Criteria Lazy Container) and have hit a problem with table refresh.
In my app I have a table showing details and status of processes. In the application I can start and finish a process and write the new status of the process to the database table (e.g. updated timestamp). I check the database and see the updated process status has been written there. I then manually click a refresh button which implements the UI table refresh, however the change in the status of the process is not updated to the UI table view.
On the other hand, as an experiment, if I manually delete a record from the database table outside of the application and then manually refresh the table the deleted record is deleted from the UI table view.
My problem is how to force the UI table to refresh and show when an associated entry is updated in the same way that the UI table view is refreshed when an entry is deleted/added to the database table?
I have a table and a refresh button, when I click the refresh button I want the table view to be updated to reflect any changes made to the associated database table, what are the main pseudo-code steps to be carried out to make this happen?
The solution for my case is to use detached entities.
For CriteriaQueryDefinition I used “setDetachedEntities(true)” and it worked as expected but for the case of BeanTupleQueryDefinition “setDetachedEntities(true)” had no effect.
To get it to work as explained in general I simply did a entityManager.clear(), before refreshing the container which essentially detached the entities and it worked, maybe not so elegant but sufficient for my case.
bean = new InboxBean();
bean.setFrom(packet.getFrom());
bean.setSubject(message.getSubject());
bean.setDate(new Date());
bean.setMessage(message.getBody());
bean.setTo(message.getFrom());
getInboxContainer().addItemAt(0, bean); // getInboxContainer() returns existing container data ,in which i update the data at 0 th index
but it update new record in table only when i click somewere on screen , please give me solution to automatic update table row when new item is get inserted