<?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 Re: Controller and JSON in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302114#M255244</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey, thanks for the reply again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to do it at share (client) side. The thing is that custom controllers are not so familiar to me. I know I get the json as field.value (one of the fields in the form uses the controller, defined in share-config-custom.xml). I wonder if I can create a javascript file for the controller that could be ran in server side. Do the controllers work the same way as webscripts? How would I run the javascript? How should I tell that to Alfresco (naming of the file etc.)? I know this post is now out of topic. I'm sorry about that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Mar 2015 08:47:31 GMT</pubDate>
    <dc:creator>sihnu</dc:creator>
    <dc:date>2015-03-17T08:47:31Z</dc:date>
    <item>
      <title>Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302109#M255239</link>
      <description>Hi,in our current project we have created a webscript that starts a workflow by definition name. The webscript works fine. Now problem is that there are some bunch of properties that should be multiplied. We thought different scenarios to solve this problem and finally we came up with a solution whe</description>
      <pubDate>Tue, 17 Mar 2015 07:39:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302109#M255239</guid>
      <dc:creator>sihnu</dc:creator>
      <dc:date>2015-03-17T07:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302110#M255240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The "EmployeeList" is a plain string and it is not a collection and as far I know, you can not convert string to JSON in FTL. Otherwise, you need to write a separate library to convert the string to JSON object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I would recommend, from the controller side, you should be able to convert the string to JSON (in Both Javascript controller + Java controller) and do the iteration in the FTL.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please let me know, if you're not clear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Murali&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 08:06:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302110#M255240</guid>
      <dc:creator>muralidharand</dc:creator>
      <dc:date>2015-03-17T08:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302111#M255241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks a lot for the response. Okay, I know how to convert json in javascript but how do I iterate the object in freemarker? I would rather do it in freemarker than in javascript.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is my script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;script language="Javascript" type="text/javascript"&amp;gt;//&amp;lt;![CDATA[&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var employees = json.parse(${field.value});&lt;BR /&gt;//]]&amp;gt;&amp;lt;/script&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;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess this should work for parsing to json object in javascript.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 08:35:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302111#M255241</guid>
      <dc:creator>sihnu</dc:creator>
      <dc:date>2015-03-17T08:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302112#M255242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I created a very simple sample webscript for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Use the eval() method to convert jsonString to JSON object in the Javascript controller.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you're using java controller, in the Java code, convert the json string to JSON object. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;strong&amp;gt;employee.get.js&amp;lt;/strong&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;var jsonString = '[{"name": "Fred Bloggs", "email": "fred@test.com", "id": "123456"},{"name": "John Smith", "email": "john@test.com", "id": "456789"},{"name": "Bob Brown", "email": "bob@test.com", "id": "987654"}]';&lt;BR /&gt;&lt;BR /&gt;//use the eval method to convert jsonString to JSON object.&lt;BR /&gt;&lt;BR /&gt;model.employeeLis = eval('(' + jsonString + ')');&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;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;strong&amp;gt;employee.get.json.ftl&amp;lt;/strong&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;#list employeeList as emp&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;${emp.name}&lt;BR /&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;strong&amp;gt;employee.get.desc.xml&amp;lt;/strong&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;webscript&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;shortname&amp;gt;example-webscript&amp;lt;/shortname&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;description&amp;gt;Simple Webscript&amp;lt;/description&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;url&amp;gt;/com/quanitcate/example&amp;lt;/url&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;format default="json"&amp;gt;any&amp;lt;/format&amp;gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; &amp;lt;authentication&amp;gt;user&amp;lt;/authentication&amp;gt;&amp;nbsp; &lt;BR /&gt;&amp;lt;/webscript&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;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps you !&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 08:35:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302112#M255242</guid>
      <dc:creator>muralidharand</dc:creator>
      <dc:date>2015-03-17T08:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302113#M255243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Where are you trying to convert json string to JSON object ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In Share side or Repo side?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 08:38:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302113#M255243</guid>
      <dc:creator>muralidharand</dc:creator>
      <dc:date>2015-03-17T08:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302114#M255244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey, thanks for the reply again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to do it at share (client) side. The thing is that custom controllers are not so familiar to me. I know I get the json as field.value (one of the fields in the form uses the controller, defined in share-config-custom.xml). I wonder if I can create a javascript file for the controller that could be ran in server side. Do the controllers work the same way as webscripts? How would I run the javascript? How should I tell that to Alfresco (naming of the file etc.)? I know this post is now out of topic. I'm sorry about that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 08:47:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302114#M255244</guid>
      <dc:creator>sihnu</dc:creator>
      <dc:date>2015-03-17T08:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302115#M255245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I could create a web script that returns HTML and then I could include that to my template. I guess that could work if I can't do it straight away. Thanks, this is nicer solution than creating the fields with javascript.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 08:50:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302115#M255245</guid>
      <dc:creator>sihnu</dc:creator>
      <dc:date>2015-03-17T08:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302116#M255246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To know more about webscript, please use the below uris.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://wiki.alfresco.com/wiki/Web_Scripts" rel="nofollow noopener noreferrer"&gt;https://wiki.alfresco.com/wiki/Web_Scripts&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://wiki.alfresco.com/wiki/Web_Scripts_Examples" rel="nofollow noopener noreferrer"&gt;https://wiki.alfresco.com/wiki/Web_Scripts_Examples&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are already out of box share webscripts are available with similar approach.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Share webscript reads the data from repository and do the iteration in the html.ftl file rather than the json.ftl file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;People prefers .html.ftl to bind the data directly to the page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For ex, dashlets are built by using webscripts. It takes the data from the repository and renders it directly in the dashlets and few dashlets calls the repo webscript directly from the client-side javascript and renders the data into dashlets.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My Tasks Dashlet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; It uses the AJAX request (my-tasks.js) to get the data from the repository and it uses the YUI datatable to render the data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Site Members Dashlet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; It reads the data from repository by using "colleagues.get.js" to read the data and it uses "colleagues.get.html.ftl" file to render the site members.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Controllers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Controller is a part of webscript.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Running Javascript.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If it is client side javascript, you need to include the javascript in the .headd.ftl file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If it is a controller javascript, follow the proper webscript naming convention to execute the server side javascript file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please let me know, if you're not clear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 09:31:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302116#M255246</guid>
      <dc:creator>muralidharand</dc:creator>
      <dc:date>2015-03-17T09:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302117#M255247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try &amp;lt;#assign jsonVariable = string_variable?eval&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:55:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302117#M255247</guid>
      <dc:creator>rjohnson</dc:creator>
      <dc:date>2015-03-17T12:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: Controller and JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302118#M255248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this is exactly what I wanted and now it works! Thanks a lot. I already created webscript for converting json to html where I first "converted" String to JSON and returned HTML However, I got the same error as before. Freemarker didn't treat the value as json object/array (the freemarker template in webscript). I think I don't need the extra webscript for converting anymore. I'm pretty sure this should work in the controller template as well.I just need to test it. Once again thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 14:18:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/controller-and-json/m-p/302118#M255248</guid>
      <dc:creator>sihnu</dc:creator>
      <dc:date>2015-03-17T14:18:03Z</dc:date>
    </item>
  </channel>
</rss>

