André Stannek
André Stannek

Reputation: 7863

Get active Window in UI

I'm using a Vaadin-UI with a servlet like this:

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = MyUI.class, widgetset = "widgetsets.MyWidgetSet")
public class MyServlet extends VaadinServlet {

}

@Theme("mytheme")
@PreserveOnRefresh
@Push
public class MyUI extends UI {
    @Override
    protected void init(VaadinRequest request) {
        Navigator navigator = new Navigator(this, this);
        navigator.addView("myView", MyView.class);
        // add some other views
        navigator.navigateTo("myView");
        setNavigator(navigator);
    }
}

public class MyView extends VerticalLayout implements View {
    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
         // init UI stuff
    }
}

It works fine so far but what I want to do now, is to use the ConfirmDialog Add-on from inside my view. My problem is that all of the ConfirmDialog.show() methods require a Window as a parameter. How can I obtain the active Window object isnide View or UI classes? UI.getCurrent().getWindows() is empty and all the examples I found use an Application class.

Upvotes: 1

Views: 3056

Answers (1)

cfrick
cfrick

Reputation: 37008

Version 1 of the addon uses an existing window (create one and pass it, as Vaadin only has Page and UI by default, a Window is just an component). With version 2 of the addon you pass only the UI, where the dialog (which subclasses Window) will show itself.

Upvotes: 3

Related Questions