Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin BeanItemContainer and Spring Roo
So I tried to pizzashop example with Spring Roo and Vaadin. But I am not using the default scaffolding UI generated by Vaadin plugin.
So I have a table with the data source of BeanItemContainer. I directly call addBean to add persisted Topping object to it.
My question is, how do I correctly update the Topping object, especially a series of updates?
Here's some pseudo code:
Topping t = new Topping();
beanItemContainer.addBean(t);//so far so good
t.merge(); //Should I explicitly call merge here?
t.merge(); //this merge will throw an exception of "cannot be merged because it has changed or been deleted since it was last read."
//alternatively I can do this
Topping t2 = t.setName("Mushroom");
Now my question is, I assume I should update the reference in beanItemContainer to t2. How do I do that? I don't think I am using the best practice here.
Could anybody enlighten me on the persistence / entity manage / transaction manage in vaadin and spring roo?
The roo/vaadin combination uses the opensessioninview filter (see web.xml) which basically means vaadin (or you) can make changes to entities and the changes will get persisted back to the db next time the entitymanager flushes. You can force this by calling entity.flush() on an instance, or EntityClass.entityManager().flush(), or just leave it to manage the persistence (they are 'managed' entities after all ;))
That's the theory, hope that helps a bit!