Don't Convert Data in a Renderer

Renderer plug-ins are responsible for marking up field values with HTML for presentation. Converter plug-ins are responsible for converting the server interface property values from their Java object representations to strings formatted appropriately for the active user. Endeavor to maintain this separation of concerns and avoid converting data within a renderer plug-in.

The format method of converter plug-ins, described in the Cúram Web Client Reference Manual, is called by the CDEJ when servicing the get method calls on the DataAccessor within the renderer. The format method is responsible for converting the Java object representation of a server interface property value to a string. The method applies the active user's locale, time zone, date format and other preferences as appropriate. Implementing this processing in a renderer is redundant, complicated and prone to error. It can also introduce inconsistencies with the presentation of the same type of data in other places in the application. Where the data is not available in a suitable format, consider developing a new converter plug-in to produce the required string representation before developing the renderer plug-in.

Where the data to be converted is retrieved from an XML document, configure and use the SimpleXPathADCMarshal class as the domain marshal. When the XML has a suitable form, this domain marshal will automatically invoke the correct converter class for the data, parse it from its generic string representation to a Java object representation and then format it to a string representation appropriate for the active user. This domain marshal is introduced in A Photograph Widget and described in detail in Extending Paths for XML Data Access.