使用jopendocument与coldfusion/railo,如何添加表格行?
我正在使用 jopendocument 1.2 和 Railo 3.3.1.000,
来自 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);
如何在 cfml 中编写该代码,或者任何有 jopendocument 经验的人都可以使用 cfml 在 odt 模板文件中添加行?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用 CF 术语来说,该代码创建一个结构体数组。因为 java 是强类型的,所以代码使用泛型来指示每个对象包含什么类型
,幸运的是,CF 数组在内部是
java.util.List
对象,而结构是java.util.Map
> 对象。因此,您只需要使用正确的键和值创建一个 CF 结构数组。然后将数组传递给template.setField(...)
。我不确定在结构中使用哪些键,因此我从 jOpenDocument-template-1.2.zip。它显示每个结构应包含三 (3) 个键,每个键对应表中的每一列:
name
、min
、max
。只要您使用字符串填充结构,就应该可以工作: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: