I have a model window which gets opened when i clicked on a Table column. My requirement is that I need to close this pop up model window when the user clicks any where
Out side of the Model window. Just as how it is done in any face book page when we see any photo’s. Could you suggest how this can be achieved using VAADIN.
final Window popupRiskDataWindow = new Window();
popupRiskDataWindow.setModal(true);
popupRiskDataWindow.setDraggable(false);
popupRiskDataWindow.setResizable(false);
popupRiskDataWindow.setScrollable(true);
popupRiskDataWindow.setClosable(true);
popupRiskDataWindow.center();
popupRiskDataWindow.addStyleName("HCMUThreatInfo");
popupRiskDataWindow.addComponent(riskData);
final VerticalLayout content = (VerticalLayout) popupRiskDataWindow
.getContent();
content.setSizeUndefined();
content.setMargin(false, true, true, true);
// Add window closing listener
popupRiskDataWindow.addListener(new Window.CloseListener() {
private static final long serialVersionUID = 2903662733997645927L;
@Override
public void windowClose(final CloseEvent e) {
// Remove the pop up window and navigate to client view
for (Window w : app.getMainWindow().getChildWindows()) {
app.getMainWindow().removeWindow(w);
}
presenter.navigateToClientView(task);
}
});
app.getMainWindow().addWindow(popupRiskDataWindow);
The pop up window has a close button but it should also close when clicked any where outside of it.
It’s really useful! Thanks.
But only works if you don’t add some focusable components to the Window, it will close.
I added some buttons to the window and each time I click on them the window closes and the action is not executed.
Is there a way where even if you focus some component inside the window dont lose the window focus?
There is one problem with this approach: In my scenario, I have buttons inside the window. Now when clicking on these buttons, the blur event on the window happens before the button gets the click event, thus the action is not executed.
I think this is because the window is closed before button can even receive the click event. I was seeing messages like this:
com.vaadin.client.communication.MessageSender WARNING: All RPCs filtered out, not sending anything to the server