The best practice ( not just for Vaadin ) is that your EntityManager should be short lived, in your case you should put the EnityManagerFactory in your AppUI , in your views you create the em, use it and close it.
Creating an EntityManager is a cheap , creating the EnityManagerFactory is expensive.
Personally I keep the EntityManagers and Factories out of my UIs and Views, I try to use a MVP pattern where possible and only the Presenter / Controller has access to the EntityManager…
Also to make things easier look at the vaadin-cdi , Spring Integration addon or cdi-utils ( now split into ‘CDI MVP’ and ‘CDI Properties’ ), you can use CDI to inject an EntityManager instance into the presenter or view.