-
1. Re: SwingWorker and the Event Dispatcher Thread
pmuir Mar 4, 2007 2:13 PM (in response to smokingapipe)An asynchronous event? You could get it to write out a progress string/number and poll that using ajax (nothing in Seam at the moment to do this easily I think... - but Shane would know better)
-
2. Re: SwingWorker and the Event Dispatcher Thread
smokingapipe Mar 4, 2007 2:31 PM (in response to smokingapipe)Well, SwingWorker itself is a lot different from just handling things asynchronously. It's a thread class that you sub-class, and you have a few methods:
doInBackground: When the SwingWorker is executed, this is the part that starts running. Obviously it happens in a thread so the GUI keeps on redrawing and responding to events. This is the essence of good Swing app building. doInBackground can publish notifications to...
process(): This receives information of various types from doInBackground and CAN safely update the GUI. process() runs on the EDT and must return quickly.
and finally...
done(): this runs on the EDT after everything else is done.
This is the only right way to handle things in Swing (either using SwingWorker or some other similar thread-based model). And many processes on the web are similar. The web request must return promptly, just like things on the EDT must return promptly. Long-running work should not be done either during the web request or on the EDT, for similar reasons. In both cases we would like a publish() method to update the user of the status of long-running work. And in both cases we want a done() method to let the user know that the long-running task is done.
MDBs are not as light-weight or as natural of a fit as SwingWorker, but they're one of the few ways I can see to do things asynchronously within the Seam world. I could be totally wrong on that of course, being a newbie to it. -
3. Re: SwingWorker and the Event Dispatcher Thread
pmuir Mar 4, 2007 2:57 PM (in response to smokingapipe)Well the main way of doing things asynchronously in Seam is to use @Asynchronous methods. Sure, it's not SwingWorker but it and ajax (and perhaps using Seam events) give you all the tools you need to do what you describe in your first post.
MDBs are for communicating between java programs (JMS) and with legacy code (JCA). -
4. Re: SwingWorker and the Event Dispatcher Thread
smokingapipe Mar 4, 2007 3:00 PM (in response to smokingapipe)Ahh, ok, I said I was a Seam newbie and now it is confirmed. I need to look up @Asynchronous because from the name of it, that sounds like what I want.