List<Map<String, String>> months = new ArrayList<Map<String,
String>>();
In CF terms, that code creates an array of structures. Because java is strongly typed the code uses generics to indicate what type of objects each one contains
List< Map<...> > // Array containing structures
Map< String, String > // Structure containing "String" values
Fortunately CF arrays are java.util.List
objects internally and structures are java.util.Map
objects. So you only need to create a CF array of structures with the proper keys and values. Then pass the array into template.setField(...)
.
I was not sure which keys to use in the structure, so I downloaded the "test.odt" template from jOpenDocument-template-1.2.zip. It revealed each structure should contain three (3) keys, one for each column in the table: name
, min
, max
. As long as you populate the structures with strings, this should work:
// Create an array of structures. Each structure represents a table row.
// The key names for columns 1-3 are: "name", "min", "max"
months = [
{name="January", min="-12", max="3"}
, {name="February", min="-8", max="5"}
, {name="March", min="-5", max="12"}
, {name="April", min="-1", max="15"}
, {name="May", min="3", max="21"}
, {name="June", min="5", max="32"}
];
// populate table rows
template.setField("months", months);