ViewChangeListener wait for User Input

In my application I use the ViewChangeListener to decide whether the user is allowed to see the next view or not.
Within the method beforeViewChange I want to open a Popup with:

Window loginWindow = new Window();
loginWindow.setModal(true);
UI.getCurrent().addWindow(loginWindow);

The Window will ask for user and password. If the user entered valid datas, then the beforeViewChange should return true otherwise false.

Unfortunately the beforeViewChange is not waiting for the user input. In fact it opens the loginWindow and continous immediately.

Does anybody know how I can wait for the user input within the beforeViewChange method or exists another way to solve this problem?

Many thanks in advance for your response.
chris

ps. I’m using Vaadin 7

I don’t think there is a way to do it how you described it, as “pausing” in a method is not possible. You can only really “pause” a Thread.
What you should do is to create the Login instead of initialize the View Change and execute the ViewChange only when the Login is successful.
Disclaimer: I don’t use Views so i can’t answer detailed questions to this topic