Implementing MVC with Vaadin and JPA


I’m new to the forum. I have been working with vaadin like one year ago. I’m trying to improve the way I have been implementing it. At the moment, I develop applications using Vaadin for the view and JPA for the persistence, but I’m not still clear in the approach of the Vaadin JPAContainer and beans. I know there are many MVC models that can be implemented, but the principal purpose is to separate the view, logic and model layers. The view is handled by vaadin, the model by JPA and I’m still not clear where to place the logic. Maybe is that the principal purpose of the beans?. The JPAContainer is used to bind data from model to the components in the view, but, is a good practice to create own classes where I place bussiness logic and retrieve the data from JPA entities, so in the view is only necessary to instance them and use CRUD operations via this classes?. Thank you for your attention and replies!. Peace.

Personally I see JPAContainer as part of the View , it is a convenient way to get filterable container for a Table.

Most of the applications I have done with Vaadin so far had some third party source data , meaning that the JPA entities merely present a convenient cached view of the actual data ( Email , Domain management via EPP , Legacy systems with web-services etc ) , and for cases like these I still place my logic into EJB stateless beans ( in the ejb module ) , unless you have a really simple application where you can directly edit entities with JPAcontainer you will always have logic in a stateless bean.
With this in mind my entity edit views usually work on a detached entity , and it is passed to the stateless bean for the actual operation ( create, detele , update ) …

Check out the cdi-utils addon , it has a nice separation from the view and the presenter ( MVP ) .