| The Freemarker class is a class you remote with DWR which accepts input
data, and the name of a Freemarker template, and it generates output using
that template and data. To use it, add this to your dwr.xml file:
<allow>
...
<convert converter="bean" match="com.omnytex.FreemarkerData"
/>
<create creator="new" javascript="Freemarker">
<param name="class" value="com.omnytex.Freemarker"
/>
</create>
...
</allow>
<signatures>
<![CDATA[
import java.util.Map;
import com.omnytex.FreemarkerData;
FreemarkerData.setMapData(final Map<String, Map>
inMapData);
]]>
</signatures>
Then, call it using this form:
var d =
{ template : "aaaaa",
rootData : { bbbbb : ccccc, ... },
mapData : {
xxxxx : { yyyyy : "zzzzz", ... }, ...
}
};
Freemarker.run(d, callback );
Where:
- aaaaa is the fully-qualified name of the Freemarker template to
execute. This template must be in the classpath, and you must use slashes
to specify it rather than dot notation. For example: com/omnytex/test/ftl
- bbbbb is zero or more data elements to be placed at the root of
the Freemarker data model (ccccc is the value of the element)
- xxxxx is the key for zero or more Map elements to be inserted into
the Freemarker data model (yyyyy is the key of an alement in the Map,
and zzzzz is the value fo that element)
If you are unfamiliar with the Freemarker data model, please read the
Freemarker documentation. But, in short, it is a tree structure with leaves
directly off the root, and/or a collection of Maps off the root.
author: Frank W. Zammetti |