Monday, May 11, 2009

Dynamic User Interface Generator: Metawidget v0.75

Update: the APIs shown in this blog entry have changed slightly in newer releases of Metawidget. Specifically metawidget.xml uses <array> instead of <list>. Please download the latest documentation from http://metawidget.org

Version 0.75 of Metawidget, the dynamic user interface generator, is now available. This release includes:
  • Pluggable widget libraries
  • SwingX support
  • DisplayTag support
  • Improved documentation

'Pluggable widget libraries' represents a significant refactoring of the widget generation code, intended to:

  • simplify support of third party libraries, including mixing multiple third party libraries in the same application
  • pave the way for supporting Collections
  • pave the way for supporting some more UI toolkits (ie. SWT)

It is also, unfortunately, a breaking change. Sorry!

Migration Guide

To migrate from v0.7 to v0.75:

Change #1: inspector-config.xml is now metawidget.xml

The role of inspector-config.xml has been expanded from configuring pluggable inspectors to configuring pluggable inspectors and widget builders. It is also now a general configuration mechanism for all aspects of your Metawidget, such as default CSS settings etc.

You will need to refactor inspector-config.xml files of the form...

<inspector-config>
   <compositeInspector xmlns="org.metawidget.inspector.composite">
      <myinspector>
      <...
      </myinspector>
</inspector-config>
...to be metawidget.xml files of the form...

<metawidget>
   <swingMetawidget xmlns="org.metawidget.swing">
      <inspector>
         <compositeInspector xmlns="org.metawidget.inspector.composite">
            <list>
               <myinspector>
               ...
               </myinspector>
            </list>
         </compositeInspector>
      </inspector>
   </swingMetawidget>
</metawidget>
The main differences with this new XML format are:

  • it is now concerned with the top-level Metawidget, not just the inspectors inside it. This means you can also configure other Metawidget properties (see below)
  • method values must now be wrapped with their type (ie. <list>) - this allows us to support configuring multi-value methods such as setParameter
  • Full documentation can be found here
Use metawidget.setConfig to set this new format, instead of metawidget.setInspectorConfig.

Change #2: Metawidget.buildWidget is now WidgetBuilder.buildWidget

If you had previously extended Metawidget to add support for a third party widget, you'll need to refactor your code into a WidgetBuilder. WidgetBuilders can be configured programmatically, or with the new metawidget.xml:

<metawidget>
   <swingMetawidget xmlns="org.metawidget.swing">
      <widgetBuilder>
         <compositeWidgetBuilder xmlns="org.metawidget.widgetbuilder.composite">
            <list>
               <myWidgetBuilder />
               <swingWidgetBuilder />
            </list>
         </compositeWidgetBuilder>

      </widgetBuilder>
      <inspector>
      ...
      </inspector>
   </swingMetawidget>
</metawidget>
WidgetBuilders higher in the list get called first. If they return null the next WidgetBuilder in the list will be called. If all WidgetBuilders return null the parent Metawidget will instantiate a nested Metawidget.

Change #3: RichFacesMetawidget has been removed

To use JBoss RichFaces, you now use a regular UIMetawidget with a RichFacesWidgetBuilder. Full documentation can be found here.

Thanks!
We apologise for the disruption these changes will cause, but strongly believe they will make Metawidget a better product for our v1.0 release. All documentation and examples have already been migrated.

0 comments: