AnsweredAssumed Answered

Listing documents in specified space in webscript FTL

Question asked by benvercammen on Sep 4, 2008
Latest reply on Sep 4, 2008 by benvercammen
I've been looking for a way to list all the documents in a space with a specified name ("User Homes" / "This Is The Space") in a freemarker template. My ultimate goal is to have a webscript that displays an overview of all the documents for a certain space (eg: go to /alfresco/service/overview and get a listing of the contents of "This Is The Space"). I was thinking that this shouldn't be too difficult, just fetch the space, list the children that are documents, and I'm done. That was over 2 hours ago…

These are some of my attempts:


    <#list companyhome.childByNamePath("User Homes/This Is The Space") as node>
Which results in the following error:
freemarker.template.TemplateException - Expected method. companyhome.childByNamePath evaluated instead to freemarker.template.SimpleHash on …

So my reasoning is that the "companyhome.childByNamePath()" method returns a SimpleHash in this case, and tried to work with it as a SimpleHash, but to no avail. So after a while I gave up on this approach and started looking for an alternative…

A second and very different approach was by using XPath to find the space and list the documents. I found the following example:
and tried to modify it to serve my needs and eventually wound up with something like this:


  <#list companyhome.childrenByXPath["*//*[@cm:name='This Is The Space]"] as child>
    <tr><td><img src="/alfresco${child.icon16}"> ${}</td></tr>
… also to no avail. So I've tested the (downgraded) example from the wiki:
<#list companyhome.childrenByXPath["*[@cm:name='Data Dictionary']/*"] as child>
   <#if child.isContainer>
      <tr><td><img src="/alfresco${child.icon32}"> ${}</td></tr>
…and it turned out that it only displays the "RSS Templates" folder, and nothing else! This is strange, because there are a lot more spaces inside the "Data Dictionary" space, and it's the same when I leave out the "child.isContainer" check. For other base spaces, such as "User Homes" or "Web Projects", I didn't receive any results!

So now I am at a loss! Clearly something like this (displaying a list of items in an FTL file from a webscript) should be fairly easy. However, I didn't find any example, searching for the resulting Freemarker errors didn't bring up any solutions, and now it seems that even the basic example from the Alfresco wiki doesn't deliver on it's promise… Can anyone please tell me what I'm doing wrong or how I should go about this?

Thanks a lot!