as far as I have developed my application so far, the CDIAddon of Vaadin is a huge advantage to me. Considering the behaviour of my application, the lifecycle of every CDIView equals the lifecycle of the UI.
Is there any way to change that? Any View should only be instanced if needed (wheras “need” is defined by calling the view via navigateTo() ) and should be destroyed after navigating to
another view.
You could modify the CDIAddon to listen to a CDI navigation Event and remove bean instance from BeanManager , however a Custom CreationalContext that is aware of the Navigation state is probably more appropriate.
I map every CreationalContext instance to the view name it belongs to. When navigateTo() is called, the ViewProvider releases the context and destroys the corresponding bean.