<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Listing documents in specified space in webscript FTL in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181877#M135007</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These are some of my attempts:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;overview.get.html.ftl:&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;#list companyhome.childByNamePath("User Homes/This Is The Space") as node&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;${node.id}&amp;lt;/td&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/#list&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;Which results in the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;freemarker.template.TemplateException - Expected method. companyhome.childByNamePath evaluated instead to freemarker.template.SimpleHash on …&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;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…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A second and very different approach was by using XPath to find the space and list the documents. I found the following example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://wiki.alfresco.com/wiki/FreeMarker_Template_Cookbook#Using_XPath" rel="nofollow noopener noreferrer"&gt;http://wiki.alfresco.com/wiki/FreeMarker_Template_Cookbook#Using_XPath&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;and tried to modify it to serve my needs and eventually wound up with something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;overview.get.html.ftl:&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;#list companyhome.childrenByXPath["*//*[@cm:name='This Is The Space]"] as child&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;img src="/alfresco${child.icon16}"&amp;gt; ${child.properties.name}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;/#list&amp;gt;&lt;BR /&gt;[/code]&lt;BR /&gt;… also to no avail. So I've tested the (downgraded) example from the wiki: &lt;BR /&gt;[code]&lt;BR /&gt; &amp;lt;table&amp;gt;&lt;BR /&gt; &amp;lt;#list companyhome.childrenByXPath["*[@cm:name='Data Dictionary']/*"] as child&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;#if child.isContainer&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;img src="/alfresco${child.icon32}"&amp;gt; ${child.properties.name}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;/#list&amp;gt;&lt;BR /&gt; &amp;lt;/table&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;…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!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Sep 2008 08:33:58 GMT</pubDate>
    <dc:creator>benvercammen</dc:creator>
    <dc:date>2008-09-04T08:33:58Z</dc:date>
    <item>
      <title>Listing documents in specified space in webscript FTL</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181877#M135007</link>
      <description>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 g</description>
      <pubDate>Thu, 04 Sep 2008 08:33:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181877#M135007</guid>
      <dc:creator>benvercammen</dc:creator>
      <dc:date>2008-09-04T08:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Listing documents in specified space in webscript FTL</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181878#M135008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;#list companyhome.childByNamePath("User Homes/This Is The Space").children as node&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;${node.id}&amp;lt;/td&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/#list&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 08:52:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181878#M135008</guid>
      <dc:creator>mikeh</dc:creator>
      <dc:date>2008-09-04T08:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Listing documents in specified space in webscript FTL</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181879#M135009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mike,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still get the same error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;Exception: freemarker.template.TemplateException - Expected method. companyhome.childByNamePath evaluated instead to freemarker.template.SimpleHash on line 21, column 12 in overview.get.html.ftl.&amp;nbsp; &lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I should mention that I'm usting the 2.1 community edition?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply though!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 09:29:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181879#M135009</guid>
      <dc:creator>benvercammen</dc:creator>
      <dc:date>2008-09-04T09:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Listing documents in specified space in webscript FTL</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181880#M135010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Whoops! Sorry, we're in Freemarker not JavaScript…&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;#list companyhome.childByNamePath["User Homes/This Is The Space"].children as node&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;td&amp;gt;${node.id}&amp;lt;/td&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;BR /&gt;&amp;lt;/#list&amp;gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 10:49:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181880#M135010</guid>
      <dc:creator>mikeh</dc:creator>
      <dc:date>2008-09-04T10:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Listing documents in specified space in webscript FTL</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181881#M135011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Mike, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The syntax works better now, however, I still seem to have some sort of problem… I keep getting the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;freemarker.core.InvalidReferenceException - Expression companyhome.childByNamePath["User Homes"] is undefined&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;I've already stripped the path down to just "User Homes" but it seems that the space can not be found? Any further ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 11:38:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181881#M135011</guid>
      <dc:creator>benvercammen</dc:creator>
      <dc:date>2008-09-04T11:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Listing documents in specified space in webscript FTL</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181882#M135012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, never mind my last remark… It seems that I've set the authentication of my webscript to "guest", while somehow to reach "companyhome" (and/or the subsequent spaces) obviously the authentication should have been set set to "user", requiring me to log in as an existing user in order to run the webscript… After having changed the authentication and logging in, I do see the listings!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, another lesson learned the hard way..&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp; Thanks for your help on the syntax Mike!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 12:01:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/listing-documents-in-specified-space-in-webscript-ftl/m-p/181882#M135012</guid>
      <dc:creator>benvercammen</dc:creator>
      <dc:date>2008-09-04T12:01:04Z</dc:date>
    </item>
  </channel>
</rss>

