I am using a JPAContainer which is getting its data from a database, and I’ve got a table using that container as its data source. Seems to be working fine, except that if I add or update an entry in the table, the table itself won’t redisplay. However, if I delete an entry from the table, it does redisplay without the deleted row. So what do I have to do to get inserts and updates to redisplay the table?
I saw a thread on this topic that suggested updating individual properties of the table row, but with the JPAContainer, I’m attempting to work with the higher level entity objects - do I need to dive down to the property level? And if so, what is the best way to do that with the JPAContainer?
Currently, one way to make sure an item shown in JPAContainer is updated is to save the item using the MutableEntityProvider of the container - e.g. with with MEP.updateEntity() (updates all fields), MEP.addEntity(), MEP.removeEntity() and MEP.updateEntityProperty(). Entity providers can be shared between container instances for the same entity type, and do notify containers of the changes.
Forcing a reload of the whole container is trickier, especially when caching entity providers are used etc. If caching providers are not used, one option is to set a new JPAContainer for the component using the same entity provider. Another alternative (which also loses queued changes not yet sent to the provider) might be to call JPAContainer.discard() followed by (protected) JPAContainer.fireContainerItemSetChange(ItemSetChangeEvent).
Thanks very much… In my code, I was creating a new MutableEntityProvider to add/update/delete the data record. When I selected the existing MEP from the JPAContainer, the table does in fact redisplay. Problem solved.