I was recently asked how to go about 'plugging in' to Metawidget, and whether some places are easier to plug in to than others. There are a few options, so here we go:
Inspectors
Inspectors inspect back-end sources and turn the information they find into a common format that the front-end Metawidgets understand. It's generally less work to write an Inspector than to write a front-end Metawidget.
You can:
- inspect XML files. For example, you could inspect Commons Validator files for 'required' fields. The base class AbstractXmlInspector should be very handy for this. Good examples of extending it are StrutsInspector and HibernateInspector
- inspect annotations. For example, you could inspect some custom Spring annotations you might have. The base class AbstractPojoInspector should be very handy. Good examples of extending it are JpaInspector and HibernateValidatorInspector
- inspect other sources. For example, you could inspect a database schema for field lengths. The base class AbstractInspector should be handy, but this is the most work of the 3 inspector options
For more information, see Implementing your Own Inspector in the Reference Documentation.
Metawidgets
Metawidgets look at inspection results and choose the best components available for the target platform. Therefore it's important to be familiar writing UIs for the target platform 'by hand' before trying to build a Metawidget for it.
Desktop Metawidgets
- new layout manager. For example, you could support MigLayout and have it understand all manner of clever SwingMetawidget.setParameters. You have to extend the base class org.metawidget.swing.layout.Layout. A good example is TableGridBagLayout, which uses setParameters for numberOfColumns
- new component library. For example, you could support some SwingX components. You'd need to extend SwingMetawidget and override its buildWidget method
- new framework. For example, you could support SWT. You can leverage all Metawidget's inspector architecture, and model your code off SwingMetawidget, but this is the most work of the 3 desktop options
Web Metawidgets
- new JSP-based framework. For example, you could support Struts 2. The base class AbstractHtmlMetawidgetTag should be handy. Good examples are StrutsMetawidgetTag and SpringMetawidgetTag
- new JSF component library. For example, you could support Tomahawk. The base class HtmlMetawidget should be handy. A good example is RichFacesMetawidget
- new JSF validators. For example, you could support some custom validators you might have. You'll need to extend org.metawidget.faces.component.validator.Validator. A good example is StandardValidator
- new layout manager. For example, you could lay out components in a 'newspaper' fashion. You'll need to extend org.metawidget.jsp.tagext.Layout (for JSP) or org.metawidget.faces.renderkit.LayoutRenderer (for JSF). Good examples are HtmlTableLayout and HtmlTableLayoutRenderer, but this is the most work of the 4 web options
Mobile Metawidgets
- new framework. For example, you could support JavaFX Mobile. You could model your code off AndroidMetawidget, but this would be a bit of work.
For more information, see Implementing your Own Metawidget in the Reference Documentation.
If anyone decides to have a go at any of these, please let me know and I'll be happy to provide all the help you need.