Question: Is there an issue working with node objects in FTL? I am using Alfresco Community 2.1.
My scenario is as follows:
Step 1:
In the JS file of the Web Script I do a lucene search to return a list of nodes.
var nodes = search.luceneSearch(searchstring);
Step 2:
I set a property in model called docnodes with the nodes
model.docnodes = nodes;
Step 3:
In the ftl file i try and access the docnodes object and it throws an error (see below for error details)
<html>
${docnodes.length}
</html>
I know that nodes is not null. I even set the number of nodes directly
model.no_nodes = nodes.length;
and was able to retrieve in the ftl file. in the JS file I am able to loop through the node using a 'for each' and see the node name, id etc etc. so I know that I have valid nodes.
Any help appreciated,
Thanks
ERROR DETAILS
The Web Script /alfresco/service/cdi/Search has responded with a status of 500 - Internal Error.
500 Description: An error inside the HTTP server which prevented it from fulfilling the request.
Message: Error during processing of the template 'Expected hash. docnodes evaluated instead to freemarker.template.SimpleSequence on line 6, column 3 in com/cdi/Search.get.html.ftl.'. Please contact your system administrator.
Exception: freemarker.template.TemplateException - Expected hash. docnodes evaluated instead to freemarker.template.SimpleSequence on line 6, column 3 in com/cdi/Search.get.html.ftl.
freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
freemarker.core.Expression.getStringValue(Expression.java:93)
freemarker.core.DollarVariable.accept(DollarVariable.java:76)
freemarker.core.Environment.visit(Environment.java:196)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:196)
freemarker.core.Environment.process(Environment.java:176)
freemarker.template.Template.process(Template.java:232)
org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:200)
org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:329)
org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:232)
org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:158)
org.alfresco.web.scripts.WebScriptRuntime.wrappedExecute(WebScriptRuntime.java:342)
org.alfresco.web.scripts.WebScriptRuntime.authenticatedExecute(WebScriptRuntime.java:308)
org.alfresco.web.scripts.WebScriptRuntime$1.execute(WebScriptRuntime.java:163)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:225)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:155)
org.alfresco.web.scripts.WebScriptRuntime.executeScript(WebScriptRuntime.java:174)
org.alfresco.web.scripts.WebScriptServlet.service(WebScriptServlet.java:109)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
java.lang.Thread.run(Thread.java:595)
Exception: org.alfresco.service.cmr.repository.TemplateException - Error during processing of the template 'Expected hash. docnodes evaluated instead to freemarker.template.SimpleSequence on line 6, column 3 in com/cdi/Search.get.html.ftl.'. Please contact your system administrator.
org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:204)
Server: Alfresco Community Network v2.1.0 (482) schema 64
Time: Feb 7, 2008 12:37:17 PM
Diagnostics: Inspect Web Script (com/cdi/Search.get)