Friday, February 13, 2009

Portable UI and re-usable controller in Java

I'm a lead developer of Swan, an end-to-end application framework for building RIA using Ajax. The current implementation supports the Java platform and has plugins for Eclipse.


One of the goals for building Swan has been the ability to build portable UIs that can be re-used in different presentation platforms. This will enable developers , responsible for supporting tools on different presentation platforms, to easily port a UI without having to re-do much of the work. Instead of maintaining a different version of the tool/product for each presentation platform we thought there should be an easier way to do this, so we created the core framework behind Swan to enable the truly separation of the View from the Model and the Controller. This was nothing new for us, the work we did was initially based on the work we had done many years back in the Smalltalk platform. Swan's framework allows us to define view builders/engines for each platform reusing the controller and the UI specs defined in XML.
The controller can then remain separate from the actual UI composition, and developers do not have to worry about creating the platform specific components. In essence we created our own UI abstraction that enables the developers to compose a UI using our widget hierarchy instead of the host widgets, hence enabling portability.
At runtime, the selected UI engine is responsible for building the actual host components and delegates the handling of events to the re-usable controller. The image below shows the same UI rendered as a SWIN based application and as a Web based app.

Swan based portable UI

In the image above you can see how the controller is reused for both presentations. Notice the highlighted code, which is called on the list click event, uses an abstracted API that is independent of the target platform: web vs. swing.
We still have work to do but we are confident that we'll be able to provide the framework capable of supporting portable UIs.

To learn more about Swan visit Swan Home Site

0 comments: