Friday, February 15, 2008

Metawidget Introduction


Developing forms to update, delete and create domain objects in a business application usually all follow the same style, layout and functionality. So would it not be great if these forms could be created at runtime instead of hand-coded. Introducing MetaWidget ...


Metawidget uses inspectors (annotations, XML and JavaBeans) to define the back-end architecture of the application and using this information constructs the front-end at runtime for numerous technologies (Swing, Andriod, Struts, JSF).

The strength of Metawidget is that is allows the developer flexibility to change how the front-end is rendered because Metawidget does not exclusively own the front-end like many other frameworks. To demonstrate this I have changed how my domain objects are presented by configuring and overriding how Metawidget renders them. I also created a single panel and dialog that could display any of my domain objects by inspecting them at runtime and applying a certain layout or style to the panel.


The model for the domain is a simple Organization, Company, Departments object model.

Showing the dialog

The following code constructs a new organization object and adds a company. The dialog and panel that use Metawidget are constructed and instructed to inspect the object and render the user interface.

The organization has a list of companies and when a company is double-clicked then a dialog showing the company is opened. This is all handled by the AbstractDomainObjectPanel class. The JTabbedPanel is an addition that I created for the demo, whereas the original rendering of Metawidget for the Organization class would have been to have each table below each other.

Screen shots

No demo would be complete without some screen shots, so here are mine.

Areas that still need work

The columns shown by the tables are still under construction and of course the editors used by the tables.

The icons for the JDialog still needs to be ironed out.

The table does not take up the correct width but for this I would need to write a new layout for Metawidget.

The close action on the main (or first dialog) does not close the application, it just sets it invisible.


Unknown said...

Talking about big framework of a project,Can it be used in the framework level of coding.

Ex. Client has asked me to do a validation in entire text field of an application,If I use a wrapper over every text field than I have to change it in one place and the validation will be on. Can i do this in Metawiget?

Unknown said...

Could you please update the picture links (they all show broken ...)