<?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 Inconsistencies in using date property in freemarker in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/inconsistencies-in-using-date-property-in-freemarker/m-p/269843#M222973</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm added a custom aspect to site on creation, and it holds a property of type date:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;type&amp;gt;d:date&amp;lt;/type&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;Now, I'm extending the &lt;/SPAN&gt;&lt;STRONG&gt;site.lib.ftl&lt;/STRONG&gt;&lt;SPAN&gt; file to display this date:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;"startdate": "&amp;lt;#if site.node.hasAspect("my:customAspect")&amp;gt;${siteNode.properties["my:customAspectDate"]?string("yyyy-MM-dd")}&amp;lt;/#if&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;Since I could not get to a site.node in the macro itself, I've extended the macro parameter list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;#macro siteJSONManagers site siteNode roles&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;SPAN&gt;so I can call it from &lt;/SPAN&gt;&lt;STRONG&gt;site.get.json.ftl&lt;/STRONG&gt;&lt;SPAN&gt; as well as &lt;/SPAN&gt;&lt;STRONG&gt;person.sites.get.json.ftl&lt;/STRONG&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;@siteLib.siteJSON site=site siteNode=siteNode /&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;Now, for site.get.js I prepare the sitenode in javascript:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;model.siteNode = site.node; // or the same with site.getNode;&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;My date is parsed correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when calling the macro from &lt;/SPAN&gt;&lt;STRONG&gt;person.sites.get.json.ftl&lt;/STRONG&gt;&lt;SPAN&gt;, I cannot prepare the site.node in javascript controller, so I do it instead in freemarker (by calling it directly):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;@siteLib.siteJSONManagers site=site siteNode=site.node roles=roles/&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;In using this form, I get this exception:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;"09090011 Wrapped Exception (with status template): 09090096 Error during processing of the template 'Expected method. siteNode.properties[\"my:customAspectDate\"]?string evaluated instead to freemarker.template.SimpleScalar on line 59, column 71 in org\/alfresco\/repository\/site\/site.lib.ftl.'. Please contact your system administrator."&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;If I just display this scallar (${siteNode.properties["my:customAspectDate"]}), I get org.mozilla.javascript.NativeDate as a string in my resulting JSON:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;"startdate": "org.mozilla.javascript.NativeDate@7a6e5e2e",&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;I can repeat that by setting the same parameter for siteNode in the site.get.json.ftl.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can even repeat it if I use siteNode.properties["cm:created"].&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems to me that when javascript controller creates a model object from a node, the created date props get created as java.util.Date, or whatever Freemarker uses, and that when Freemarker itself creates that property, it will be turned into org.mozilla.javascript.NativeDate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can somebody please point out how can I could improve my work? What can I use so that my calls get the same values?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using Alfresco from SVN HEAD if it makes any difference.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Oct 2012 17:38:54 GMT</pubDate>
    <dc:creator>zladuric</dc:creator>
    <dc:date>2012-10-09T17:38:54Z</dc:date>
    <item>
      <title>Inconsistencies in using date property in freemarker</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistencies-in-using-date-property-in-freemarker/m-p/269843#M222973</link>
      <description>Hello,I'm added a custom aspect to site on creation, and it holds a property of type date:&amp;lt;type&amp;gt;d:date&amp;lt;/type&amp;gt;‍Now, I'm extending the site.lib.ftl file to display this date:"startdate": "&amp;lt;#if site.node.hasAspect("my:customAspect")&amp;gt;${siteNode.properties["my:customAspectDate"]?string(</description>
      <pubDate>Tue, 09 Oct 2012 17:38:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistencies-in-using-date-property-in-freemarker/m-p/269843#M222973</guid>
      <dc:creator>zladuric</dc:creator>
      <dc:date>2012-10-09T17:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistencies in using date property in freemarker</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistencies-in-using-date-property-in-freemarker/m-p/269844#M222974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Aaaaaand to answer my own question, in case somebody else bumps into this wall for two days too:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;#assign nodeR=companyhome.childByNamePath["Sites/" + site.shortName] /&amp;gt;&lt;BR /&gt;"startdate": "&amp;lt;#if nodeR.hasAspect("my:customAspect")&amp;gt;${nodeR.properties["my:customAspectDate"]?string("yyyy-MM-dd")}&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;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know why it works this way and not the other, though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 17:56:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistencies-in-using-date-property-in-freemarker/m-p/269844#M222974</guid>
      <dc:creator>zladuric</dc:creator>
      <dc:date>2012-10-09T17:56:09Z</dc:date>
    </item>
  </channel>
</rss>

