AnsweredAssumed Answered

problem with ftl template.

Question asked by need on Oct 9, 2011
Latest reply on Oct 10, 2011 by scouil
Hi all,

I have a problem with a dashlet 3.4d with Alfresco Share. I have followed many tutorials but I can not solve my problem. Let me explain.

I created Alfresco webscripts makes me a search for all documents that have a certain aspect. and return a json and it works if I access the page http://localhost:8080/alfresco/service/let/modelli visualize the result in json format.


{"modelli" : [
        {"name" : "consulente.xls",
         "link" : "\/alfresco\/d\/d\/workspace\/SpacesStore\/b632375f-e6a1-40e2-a2ee-dd858a4f8dc2\/consulente.xls",
        }
]
}

Now I have created a dashlet of Alfresco Share, which should see the list of documents that have a certain aspect.

Post the code for clarity:

- getmodel.get.desc.xml

<webscript>
   <shortname>Crea da modello</shortname>
   <description>Nuovo documento da modello esistente</description>
   <!– one of dashlet, site-dashlet or user-dashlet –>
   <family>dashlet</family>
   <url>/components/dashlets/getmodel</url>
</webscript>

- getmodel.get.html.ftl

<div class="dashlet">
   <div class="title">Nuovo documento da modello esistente</div>
   <div class="body scrollableList">
     <div class="detail-list-item first-item last-item">
        <h5>Modelli di documento</h5>
      <table>
         <#list modelli as mod>
            <tr>
               <td><b>Name</b></td><td>${mod.name}</td>
            </tr>
            
            <tr>
            <td><b>Link</b></td><td><a href="${url.context}${mod.link}?guest=true">${url.context}${mod.link}</a></td>
            </tr>
         </#list>
      </table>
     </div>
   </div>
</div>

- getmodel.get.js


var connector = remote.connect("alfresco");
var data = connector.call("let/modelli");
if (data.status == 200) {
var result = eval('(' + data + ')');
model.modelli = result["modelli"];
}else{
   model.modelli="zzzz";
}

And this is  exception in tomcat log.

Exception: freemarker.template.TemplateException - Expected collection or sequence. modelli evaluated instead to freemarker.template.SimpleScalar on line 7, column 32 in org/alfresco/components/dashlets/getmodel.get.html.ftl.

I understand that the problem are in the ftl template file but I can not figure out how I can fix and what is wrong. Help me to understand?

Thank you all for the availability.

Outcomes