Add a new value formatter
Procedure
-
In Studio, edit the
ValueFormatterTypetypelist. - Add a new typekey entering a code, name, and description.
-
Instantiate the formatter and link it to your new typekey. Write code to format the value.
In the default configuration, the value formatters are instantiated in the ValueFormatter class located in the
gw.job.uwpackage. Add code to instantiate the value formatter for your new typekey. Also add code to format the value. For example, the following is the code for theIntegervalue formatter in the ValueFormatter class:final public static var FOR_INTEGER : ValueFormatter = new ValueFormatter(TC_INTEGER) { override function format(value : String) : String { return formatInteger(value) } }The code
ValueFormatter = new ValueFormatter(TC_INTEGER)links the formatter to theIntegertypekey. The formatInteger method formats the value.If you prefer not to instantiate a value formatter in the ValueFormatter class, you can instantiate it in the location of your choice. However, the value formatter must be instantiated in a class that is guaranteed to load before PolicyCenter calls the ValueFormatter.format method. For example, you can instantiate your wrappers in a startable plugin which runs after loading the database, but before serving any web pages. For more information, see Startable plugins.
Important: Failure to guarantee that the value formatter is instantiated before loadingValueFormattermay result in non-deterministic null pointer exceptions ifValueFormatter.formatreturns null for an extended typekey.
