My problem is that I need to suspend application until clicking some button in dialog window. In my application I have got some nested class extending some CustomView class (CustomView is extending Vaadin CustomComponent class). When user tries to change view from Administration View to any other, there should be shown modal dialog window asking to discarding unsaved records, but when I try to do that dialog window is shown after new view is loaded. I read some of topics about modal windows in Vaadin and I found, that I cannot make a real modal window using setModal() function.

Class CustomView {
protected abstract void init();
@Override
public void attach() {
init();
}
@Override
public void detach() {
if (this instanceof AdministrationView) {
AdministrationView view = (AdministrationView) this;
if (view.hasUnsavedRecords()) {
final ConfirmLeaveWindow window = new ConfirmLeaveWindow();
window.setModal(true);
view.getApplication().getMainWindow().addWindow(window);
if (!window.isLeaveConfirmed())
return;
}
super.detach();
this.cleanRootComponent();
}
So somehow I must prevent application from loading new view until any of ConfirmLeaveWindow buttons is clicked.