AnsweredAssumed Answered

Returning an ArrayList back to Freemarker

Question asked by bengrah on Feb 27, 2013
Latest reply on Feb 27, 2013 by afaust
Hi guys,

I've wrote a Java-backed webscript that's returning an ArrayList<String> collection which I can easily print on screen in the freemarker template

<#list list as children>
${children}
</#list>

What I want to do is return an ArrayList of NodeRefs, so that way I can reference properties of nodes on the Freemarker side. So here's my code



unlockedFilesArray.add(row.getNodeRef());
model.put("unlockedNodes", unlockedFilesArray);
return model;



Then in the Freemarker template:

<#list unlockedNodes as children>
${children.properties["cm:name"]}
</#list>

But this throws an error:


freemarker.template.TemplateException: Expected hash. child evaluated instead to freemarker.template.SimpleScalar on line 10, column 55 in org/example/javadir.get.html.ftl.


I'm sure the problem lies with the reference to the ArrayList or the syntax I'm using. Any ideas?

Thanks,
Ben.

Outcomes