Reflection and Inspecting Annotations
Whilst Metawidget does not require reflection and annotations (eg. you can just use XmlInspector), it's certainly a lot more powerful with them. By using reflection and inspecting the existing annotations on your business objects (you know, the JPA ones, the Hibernate Validator ones, etc.), Metawidget can automatically generate accurate UIs.
But! Using GwtMetawidget, you can take your business object, reflect and inspect it, and generate your UI! How is this possible?
Well, GwtMetawidget showcases the power of Metawidget's separate Inspector/renderer architecture. Metawidget comes with a range of different inspectors targeting different aspects of back-end architectures (JPA annotations, Hibernate Validator annotations, JavaBean getters/setters etc). Each Inspector returns a piece of XML, and you can use CompositeInspector to compile them all together into one.
Because of this approach, inspection can be performed anywhere and the result passed somewhere else for rendering:
The process becomes:
- GwtMetawidget uses AJAX to pass the business object to the server
- the server, using Java, runs all the Inspectors (including reflection and annotations)
- the server returns the inspection results as an XML document
How does this work in practice? See for yourself! The Metawidget download includes a pre-built sample application, addressbook-gwt.war, that showcases a GwtMetawidget using reflection and inspecting annotations at runtime to generate the UI. It's covered in detail in the reference guide.