Creating a modal window where window is Application

My webapp consists of various servlets each of which is a com.vaadin.Applications. I was wondering if it was possible to call up a modal window from an application where the modal window is actually the contents of another Application. I understand the simple workaround way would be to use window.open(ExternalResource) but I like the look and functionality of modal windows.

Here’s a sample of what I’m trying.

Application subApplication = new MySubApp();
// call init so that the windows are generated
subApplication.init();

Window mySubWindow = subApplication.getMainWindow();
// subwindow will not be added if it is already attached to an existing application
mySubWindow.setApplication(null);

// set modal stuff

// finally add
myParentApp.getWindow().addWindow(mySubWindow)

This actually pulls up the subapp into a modal window but the click handlers do not work. I think this is the next step of troubleshooting but I was wondering if anyone has tried this before or if this is even possible. Perhaps calling “mySubWindow.setApplication(null);” killed the functionality of the action listeners.

Just open a Window with an fullsized Embedded-component inside. In that Embedded you can just load your second application via ExternalResource.

Thanks that worked pretty easily and did not feel hackish like the attempt I was doing earlier. Another question, how can I close the modal embedded page now? I have a close button in the embedded application. I am trying the window.getApplication().getParent() but it is coming up as null. I am guessing this is because I am embedded so there’s no way for me to determine who the parent Application is so that I can mySubModalWin.getParent().removeWindow(mySubModalWin). The X in the top right corner of the modal window works fine.

Inter-Application-communication isn’t very easy and forces you normally to dive deeper into the underlying technologies (Servlets / Portlets), although I could imagine that one can solve this using a UriFragmentChangedListener. Are you sure that you are doing the right thing anyways? A single task shouldn’t need two applications to get done. Maybe you are better off by organizing your Views as CustomComponents / subclasses of *Layout instead of Applications?