I'm using jopendocument 1.2 with Railo 3.3.1.000
from http://www.jopendocument.org/start_text_2.html
List<Map<String, String>> months = new ArrayList<Map<String, String>>();
months.add(createMap("January", "-12", "3"));
months.add(createMap("February", "-8", "5"));
months.add(createMap("March", "-5", "12"));
months.add(createMap("April", "-1", "15"));
months.add(createMap("May", "3", "21"));
template.setField("months", months);
How to write that code in cfml, or anyone have experience with jopendocument to add row in odt template file with cfml?
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
Fortunately CF arrays are
java.util.List
objects internally and structures arejava.util.Map
objects. So you only need to create a CF array of structures with the proper keys and values. Then pass the array intotemplate.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: