CDI Event binding

i’am new to vaadin and i use vaadin with the cdi extention. I created a View with some Input elements.
On buttonclick i open a subwindow where the user can select some things. This things need to be transfered to the forms of the view. I want to transport the selection via an event back to the view. But the Observer Method never gets called.
This Feature is essential for my application because i want to decouple the window from the view to use the window on many places inside this and other applications.

Here is some code of what i try to do.


public class Search extends VerticalLayout implements View{

private TextField test;
private Button testButton;

//… layout stuff and add window in button clicklistener

public void listenToSelection(@Observes(notifyObserver = Reception.IF_EXISTS) SelectionEvent event){

public class SearchWindow extends Window{

javax.enterprise.event.Event<SelectionEvent> selectEvent;

//call; somewhere


The listenToSelection Method never gets called. Any idea how to fix this problem? Has it something to do with the different Scopes of the View and the Window?


Try removing the
annotation in your
class (the view implementation). With this change, the view won’t retain its state when the user navigates to another view (it will have view scope).

jep this works. But i have to retain the view state (it is a customer request). Is there any other way?

I tested it and it works in views with
when the observer method is not conditional (without
notifyObserver = Reception.IF_EXISTS
or with
notifyObserver = Reception.ALWAYS
). So, the problem might be related to scopes.

thank you for the reply and sorry for the long delay. I was out for holiday :wink:

To the problem. I added
notifyObserver = Reception.ALWAYS
to my observer and you are right, the view observer gets the event. But in the wrong instance of the view. It seems like it creates a new instance of the view and sets the values.

I have a second window in the same view with the same task to let the user select some things and transfer it on button click to the main view. ​Interestingly those windows seem to share the same Instance of the view but not on the “right” instance.

Any ideas how to get it in the “right” view?

I’d avoid coupling the UI with my data and use a SessingScoped bean for passing data back and forth. My two cents. I personally like to keep the view layer as decoupled as possible