I’ve been looking into this whole XWork + Swing thing a little more, and have come up with a fairly simplistic example of how a Swing+XWork framework might look. If you want to follow the code I suggest you read my brief “XWork tutorial(A Simple Xwork Example)”:http://www.magpiebrain.com/archives/000180.html. Anyway, my example shows a simple window with a button and a progress bar. When clicked, the button invokes an XWork
Action on a thread. A ProgressInterceptor records when the action starts and ends, and changes the state of the onscreen progress bar as appropriate.
The Action has to be run on a seperate thread, as otherwise it will be invoked on the Event thread, blocking any GUI updates until the action has returned. This means that the return from
execute method cannot be handled – we have moved from synchronous action invocation to asynchronous action invocation. The
ProgressInterceptor calls methods on a
ProgressRegister singleton to tell it when an Action has started or stopped. I dislike the use of a singleton, but right now it is impossible to pass objects into an Interceptor (this is a nasty constraint of XWork – I might see how easy it would be to use Spring to create Interceptors). A
ProgressListener gets registered with the
ProgressRegister, and updates a
JProgressBar as required.
Its actually a lot simpler than it sounds – check the code for yourself to see. It represents an afternoon of work so is a little rough and ready – you’ve been warned! To run the program the main class is
org.magpiebrain.example.TestProgram. The code requires webwork1.0, OSCore, OGNL and commons-logging to run, all of which are included in the zipfile. If I decide to take this much further I will look into supporting SWT, so suggestions as to how easy this would be are welcome. Note that the only GUI feedback from the action is by the progress bar at present – I need to think about the interaction between the result of the Action and its impact on the GUI a little more.
8 Responses to “A GUI framework using XWork”
I guess you mean xwork1.0 an not webwork1.0.
Anyway, that is all very nice, but I’de really like to see Remote Xwork Action invocation. There is some work started on this (see http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-234)
and although it’s webwork based, I think could be striped of ww dependencies and be able to provide
a Xwork clean way of invoquing action remotely.
I hope to have some time soon, to work on this, and provide a few simple samples…
Yep, meant webwork not xwork 🙂 Remote XWork invocation shouldn’t be too hard – I’m guessing you just need to use an ActionInvocation as a proxy wrapping underlying RMI calls. The JIRA link you provided doesn’t work by the way.
the issue exists, it’s just that the ‘)’ got somehow inside the URL 🙂
Your idea for a swing framework looks pretty good, and I came across it because I was thinking about producing something similar – but figured someone must have done it before.
After many hours searching the web however, I came up with zip and started out by coding my own. I am currently still throwing ideas around – but something I was quite keen on introducing was a way of ‘binding’ component value properties to their corresponding action properties. This technique has been used by the likes of webwork and tapestry.
I’m going to keep pushing on with my code, but your idea definitely sounds as if it could be more robust, and I look forward to seeing more of it!
Work has stalled at present due to a new job. In the mean time you might want to look at the spring-rcp project: http://www.springframework.org/spring-rcp.html
If I do get to do any more work on this, it will probably be folded into spring-rcp rather than being its own framework.
I just read your blog, and was quite intrigued. I started a project called SwingWork a couple monthes ago with the hope to flesh out a more comfortable execution environment for XWork and Swing. I would be very interested to hear your comments (and if you’re interested involvement) with this project!
I’d certainly like to look at what you’ve done Ryan, although as far as getting involved goes my plate is very full – I’m currently working on a NakedObject’s related project. In fact it sounds like your work may be of use further down the road.
I had a look at the Spring-RCP (or Rich C), and although Keith has done a great job so far, I was a bit confused about how to handle an application which required posting results to new panels in say… a tabcontainer.
So I picked up on where I’d left off and have pushed on with the development of an XWork based framework. It’s now on it’s first Release Candidate and if you’re at all interested, it’s available at: http://www.sourceforge.net/projects/pendulum