Data format for serializing objects as HTML.
Template Lookup
When serializing an object the following this class looks up a template using the following methods:
- The result of {@link #getTemplateName(Object)} if not null.
- The resource uri being requested. If the requested uri is "/rest/foo" then a template named "foo.ftl" is searched for.
- The class of the object being serialized. If an object of org.acme.Foo is being serialized then a template named "Foo.ftl" is searched for.
Template Variables
Variables provided to the template are created via reflection on the object being serialized and placed into a map called "properties". For instance consider the following class of object:
class MyObject { String getFoo(); Integer getBar(); }
In the template values for the properties "foo" and "bar" would be available via:
${properties.foo} ${properties.bar}
A variable called "page" is also provided which contains information about the resource being accessed. See {@link #createPageDetails(Request)} for more details.
Reflection
The template data model is created reflectively via the {@link ObjectToMapWrapper} class. This class can be extended to provide custom properties. See the javadoc for more details.
@author Justin Deoliveira, OpenGEO