ZK 3.6.3 - Closing Modal Windows on InterruptedException
16 Mar 2010 14:21:51 GMT
18 Mar 2010 20:30:15 GMT
18 Mar 2010 20:30:15 GMT
@mpassell, welcome to zk.
I think your approach is the easiest solution I know.
8 Apr 2010 10:44:24 GMT
8 Apr 2010 10:44:24 GMT
Thanks Peter.
Just in case anyone is interested, when I tried the same technique on modal dialogs/windows opened by the Messagebox.show() methods, it didn't work. I took a look at the source for Messagebox and discovered that the exception handling code had a few lines in the wrong order. I opened Bug 2975362 and submitted a patch. It was checked in and will be part of ZK 3.6.5 and the next 5.0.x release.
--Matt
ZK - Open Source Ajax Java Framework
The ZK app I'm working on occasionally needs to close all of the ZK Windows open on all Desktops. I set this up for non-modal windows fairly easily, but modal windows were considerably more difficult. I use the following code to cease all suspended threads for a given desktop.
DesktopCtrl desktopCtrl = (DesktopCtrl)desktop; Collection<List<EventProcessingThread>> threads = desktopCtrl.getSuspendedThreads(); synchronized (threads) { for (List<EventProcessingThread> threadList : threads) { if (threadList.isEmpty()) { continue; } List<EventProcessingThread> tempList = new ArrayList<EventProcessingThread>(threadList); for (EventProcessingThread thread : tempList) { if (thread.isSuspended()) { if (desktopCtrl.ceaseSuspendedThread(thread, "responding to ShutdownEvent")) { logger.debug("suspended thread ceased"); } else { logger.info("unable to cease suspended thread"); } } } } }Then, in response to the InterruptedException that gets thrown, I call Window.onClose() on the modal Window.
try { w.doModal(); } catch (InterruptedException e) { w.onClose(); throw e; }Is there an easier way to do this? If not, I'll have to go through all 20+ places we're using modal dialogs and wrap them in similar try/catch blocks. It's a common enough problem I might even use AOP to make sure all callers of doModal() are wrapped.
Thanks,
Matt