<?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 Hint of the day #2 : Creating a Map or Seq. with Freemarker in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208369#M161499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This example enumerate all the associations of the root node "person".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Each association value is a nodeRef to a node of type cm&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://connect.hyland.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;erson&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hence, this freemarker script list the usernames associated with the current person : allow to represent a human hierarchy inside a company.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In two steps :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Create the Map "as string"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Cast the string to a Map object with the instruction :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;#assign map = mapAsString?eval/&amp;gt;&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;3) Test for NON existence of a key in the map :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;#if !map["keynotexist"]??&amp;gt;&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;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;#assign mapAsString = "{"/&amp;gt;&lt;BR /&gt;&amp;lt;#assign first = true /&amp;gt;&lt;BR /&gt;&amp;lt;#list person.assocs["cm:subscribedBy"] as subscriber&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;#if first = false&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;#assign mapAsString = mapAsString + ","/&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/#if&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;#assign mapAsString = mapAsString + "\"" + subscriber.properties["userName"] + "\":" + "\"" + subscriber.properties["userName"] + "\""/&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;#assign first = false/&amp;gt;&lt;BR /&gt;&amp;lt;/#list&amp;gt;&lt;BR /&gt;&amp;lt;#assign mapAsString = mapAsString + "}"/&amp;gt;&lt;BR /&gt; &lt;BR /&gt;&amp;lt;#assign map = mapAsString?eval/&amp;gt;&lt;BR /&gt;&amp;lt;p&amp;gt;&amp;lt;i&amp;gt;map size: ${map?size}&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt;&lt;BR /&gt;&amp;lt;#assign keys = map?keys&amp;gt;&lt;BR /&gt;&amp;lt;#list keys as key&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;${key} = ${map[key]}&lt;BR /&gt;&amp;lt;/#list&amp;gt; &lt;BR /&gt;&amp;lt;#if !map["keynotexist"]??&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;&amp;lt;i&amp;gt;key not found&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt;&lt;BR /&gt;&amp;lt;#else&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;&amp;lt;i&amp;gt;key found&amp;lt;/i&amp;gt;&amp;lt;/p&amp;gt;&lt;BR /&gt;&amp;lt;/#if&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;/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;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want a sequence, just build the String. For example "[value1,value2,…]" and then call "eval" like above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And then do traverse like in the freemarker doc reference :&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://www.freemarker.org/docs/ref_builtins_hash.html" rel="nofollow noopener noreferrer"&gt;http://www.freemarker.org/docs/ref_builtins_hash.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS : according to the freemarker doc reference order may be maintained in the map. So I'am quite suspicious that behind this is a real java map…So it means that Map and Sequence in Freemarker looks to be the same java underlying data structure : a List, because they maintained the order both.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hoping it might help someone (this hints in missing in the wiki)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 May 2009 15:27:10 GMT</pubDate>
    <dc:creator>zomurn</dc:creator>
    <dc:date>2009-05-07T15:27:10Z</dc:date>
    <item>
      <title>Hint of the day #2 : Creating a Map or Seq. with Freemarker</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208369#M161499</link>
      <description>This example enumerate all the associations of the root node "person".Each association value is a nodeRef to a node of type cm&lt;IMG id="smileytongue" class="emoticon emoticon-smileytongue" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;ersonHence, this freemarker script list the usernames associated with the current person : allow to represent a human hierarchy inside a company.In two steps :1) Create the</description>
      <pubDate>Thu, 07 May 2009 15:27:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208369#M161499</guid>
      <dc:creator>zomurn</dc:creator>
      <dc:date>2009-05-07T15:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Hint of the day #2 : Creating a Map or Seq. with Freemarker</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208370#M161500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please go ahead add your examples and hints to the wiki if you realise something is missing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2009 16:01:32 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208370#M161500</guid>
      <dc:creator>mrogers</dc:creator>
      <dc:date>2009-05-07T16:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Hint of the day #2 : Creating a Map or Seq. with Freemarker</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208371#M161501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;PS : according to the freemarker doc reference order may be maintained in the map. So I'am quite suspicious that behind this is a real java map…So it means that Map and Sequence in Freemarker looks to be the same java underlying data structure : a List, because they maintained the order both.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the cool tip on how to form a map from a string!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just wanted to point out that in Java, a LinkedHashMap maintains insertion order of the keys so the underlying structures may be different.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2009 08:46:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208371#M161501</guid>
      <dc:creator>lyamamot</dc:creator>
      <dc:date>2009-05-09T08:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Hint of the day #2 : Creating a Map or Seq. with Freemarker</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208372#M161502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As I've just seen, you might be right. That's true.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mrogers &amp;gt; I will put this hint on the wiki later so. But everyone can post on it ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2009 22:57:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208372#M161502</guid>
      <dc:creator>zomurn</dc:creator>
      <dc:date>2009-05-09T22:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Hint of the day #2 : Creating a Map or Seq. with Freemarker</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208373#M161503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, all community members can update the wiki and I'd encourage everyone to do so as and when they see something missing or not quite right.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 May 2009 21:44:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/hint-of-the-day-2-creating-a-map-or-seq-with-freemarker/m-p/208373#M161503</guid>
      <dc:creator>mrogers</dc:creator>
      <dc:date>2009-05-10T21:44:18Z</dc:date>
    </item>
  </channel>
</rss>

