I don’t see any removeWindow methods that take String as the parameter.
but I’ve tried the following and it does not work either. The code runs fine, no errors, but modal window does not close.
Button apply = new Button("Close", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
Window w = getWindow();
getApplication().removeWindow(w);
}
});
I have a class where I display a data grid and if user double clicks on the row I create a modal Window and on this window I add another VerticalLayout class and in this class I have the Close button which does not work.
The Close button works fine if I create the Button on the Modal Window, but it does not work if I create the button in the VerticalLayout Class
There are two types of windows: browser level windows (e.g. main window) and sub windows. Browser level windows are added to and removed from the application. Sub windows are added to and removed from their parent (browser level) window. What you need to do is remove the sub window from its parent window, something like
Would someone be so kind and implement the “Window.closeThisBloodyWindowForMeWouldYa()” method and get us rid of having to worry about the parent once and for all!
com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.ClassCastException: com.vaadin.ui.VerticalLayout cannot be cast to com.vaadin.ui.Window
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1107)
at com.vaadin.ui.Button.fireClick(Button.java:341)
VerticalLayout is probably the layout in the window, definitely not the window itself. Use the same Window object as you use to display the modal window.
I had a slightly different result- your code gave me an error. I have a form, to which I’ve added a Save and Cancel button beneath inside a modal Window.
What worked for me was this (in the button click event handler):