9. How To's

This chapter contains 'recipes' for various scenarios you may encounter when using Metawidget.

9.1 Order Properties

Metawidget supports several approaches to control the order of properties in the UI, depending on your architecture and your preference:

  • Annotate the properties with @UiComesAfter, use MetawidgetAnnotationInspector in your CompositeInspector chain, and use ComesAfterInspectionResultProcessor. This is the default approach.

  • Use one of the XML-based Inspectors (such as XmlInspector or HibernateInspector) as the first Inspector in your CompositeInspector chain. XML nodes are inherently ordered.

  • Compile your business model with debug information turned on, and use JavassistPropertyStyle. This approach uses Javassist to extract line numbering information, and order the properties in source file order.

  • Write your own InspectionResultProcessor. This gives you a range of options, including: sorting properties based on a page property (see Section 2.3.5, “Implementing Your Own InspectionResultProcessor”); sorting properties based on a different notation (such as Dewey Decimal); defining property order at the class (rather than the getter) level, and many more. For complete worked examples see this blog entry.