Word Template Token List Renderer
Report Parameters (${...})
The word document may contain parameters as normal text elements that are replaced. Those parameters have the form ${ParamName}.
This renderer also supports arbitrary MessageFormat patterns for all input parameters; for example ${Now,date,short} will effectively be interpreted as MessageFormat {0,date,short} with the single parameter Now from the parameter map. For more information about MessageFormat, please consult the MessageFormat javadoc.
There are multiple predefined properties that are always added to the parameter map:
${ListId}contains the token list's ID${DateString}contains the current date already formatted as string${Now}contains the current date as Date object${ExpirationDate}contains the token list's expiration date already formatted as string${ExpirationDateObject}contains the token list's expiration date as Date object${ListGenerationDate}contains the token list's generation date as Date object${NumberOfTokens}contains the total number of tokens in the current list${T*}contains a single token value, where*is an integer starting at zero. So the first token value will always be${T0}whereas the 100th token will be${T99}
Some of the above parameters contain a timestamp and can be used for both date and time display. Since this represents a Date object, it can be formatted directly using MessageFormat, for example:${Now,date,short} displays a short date using the user's locale; for example: 09.01.12.
Alternatively, a date format can be specified in a SimpleDateFormat compatible form, for example:${Now,date,dd.MM.yyyy} resulting in 09.01.2012.
This token list renderer allows to pass arbitrary parameters to the conversion engine: the parameter map passed to the renderTokenList() method is forwarded to the report engine. Thus, when placing the parameter Salutation with value "Dear Mr. Smith" into the parameter map when calling this renderer, you can display this value in the document using ${Salutation}.
Adding images is also supported by adding an instance of BufferedImage to the parameter map. This image replaces the entire text node where the parameter was found and is inserted as an inline image. Make sure there's enough place for that image in the template document.
Handling Multiple Languages
You can have this renderer use different documents for rendering depending on a language.There must always be a default template configured which is used if there's no specific template defined for the passed-in language. Additionally you can define a specific template for every language expected.
Templates are read in when the renderer is initialized and are kept in memory by the renderer. Thus, reusing the renderer instance improves efficiency as the document needn't be re-parsed on every call.
tokensPerRow) It has no influence on the rendered letter; the row labels are generated from the Word template. This property must be adjusted according to the letter design.
This property has no effect when using token lists or indexed lists.
zeroBasedRowIndices) This property is used to correctly translate the matrix card coordinates back to internal indices. It has no influence on the rendered letter; the row labels are generated from the Word template. This property must be adjusted according to the letter design.
This property has no effect when using token lists or indexed lists.
defaultTemplate) Supported formats are: DOC, DOCX, RTF and ODF.
The file name is either absolute or relative to the JVMs current directory.
Multiple templates for different languages can be specified with the property template. There must always be a default template.
template) Selectors must be chosen according to the ISO-2-letter language codes, i.e. "fr" for french.
See also description of default-template.
saveOptions)
type: WordTemplateTokenListRenderer
id: WordTemplateTokenListRenderer-xxxxxx
displayName:
comment:
properties:
defaultTemplate:
saveOptions:
template:
tokensPerRow: 10
zeroBasedRowIndices: false