<?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: Attempting to store JavaScript objects to process variables fails in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198570#M151700</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;JSON.stringify would a fine approach to store the variable as a JSON String in the database. The other approach is to use a Serializable Java type instead like mentioned by pkonyves. Don't see any other approach actually.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Nov 2014 10:31:35 GMT</pubDate>
    <dc:creator>trademak</dc:creator>
    <dc:date>2014-11-27T10:31:35Z</dc:date>
    <item>
      <title>Attempting to store JavaScript objects to process variables fails</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198567#M151697</link>
      <description>The following script task fails:&amp;lt;javascript&amp;gt;var structure = {fred: 123,bill: ['x', 'y', 'z'],eric: { smoo: 'froob'}};execution.setVariable("STUFF",structure);&amp;lt;/javascript&amp;gt;It fails because findVariableType() in DefaultVariableTypes.java cannot locate an appropriate type for storage.The re</description>
      <pubDate>Wed, 26 Nov 2014 16:30:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198567#M151697</guid>
      <dc:creator>andrewlecouteur</dc:creator>
      <dc:date>2014-11-26T16:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to store JavaScript objects to process variables fails</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198568#M151698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, try creating a serializable object. Search for 'serializable' on this page, maybe you can get some ideas: &lt;/SPAN&gt;&lt;A href="http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html" rel="nofollow noopener noreferrer"&gt;http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 19:08:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198568#M151698</guid>
      <dc:creator>pkonyves</dc:creator>
      <dc:date>2014-11-26T19:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to store JavaScript objects to process variables fails</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198569#M151699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I really want to implement this in a way that leaves the scripts "looking" like JavaScript.&amp;nbsp; One solution is to use&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;javascript&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; execution.setVariable("STUFF", JSON.stringify(structure));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/javascript&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but this seems rather arbitrary.&amp;nbsp; Surely there is some way that the code shown above can be made to work?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Nov 2014 09:31:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198569#M151699</guid>
      <dc:creator>andrewlecouteur</dc:creator>
      <dc:date>2014-11-27T09:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to store JavaScript objects to process variables fails</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198570#M151700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;JSON.stringify would a fine approach to store the variable as a JSON String in the database. The other approach is to use a Serializable Java type instead like mentioned by pkonyves. Don't see any other approach actually.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Nov 2014 10:31:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198570#M151700</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2014-11-27T10:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to store JavaScript objects to process variables fails</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198571#M151701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have now implemented a method whereby JavaScript objects can be stored and retrieved directly to/from process variables.&amp;nbsp; This involves the use of private code in the sun.org.mozilla.javascript.internal namespace but this interface is very unlikely to change and, in any case, there is no alternative if you are using the JavaScript engine in rt.jar.&amp;nbsp; It could be made more legitimate by using the original js.jar from Mozilla but I am unsure if this can be substituted without any issues in the rest of the Activiti code-base.&amp;nbsp; I suspect that it can.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;JavaScript objects and arrays are serialised to JSON for storage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code will, of course, need to be revisited when we eventually move to Nashorn but that isn't a major concern for our purpose.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess that the use of a private API will mean that this code will never be suitable for inclusion in the Activiti project but it can be done and it isn't that hard once you find the correct documentation.&amp;nbsp; The Oracle documentation is quite useless but the original documentation for org.mozilla.javascript is very helpful.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If anyone wants a copy of my code then please ask.&amp;nbsp; If there is enough interest I will put it somewhere publicly accessible. &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Nov 2014 15:36:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198571#M151701</guid>
      <dc:creator>andrewlecouteur</dc:creator>
      <dc:date>2014-11-28T15:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Attempting to store JavaScript objects to process variables fails</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198572#M151702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for writing that up. The problem is indeed that the JS engine inside of the JVM is &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) sucky at many places&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) depending on the vendor &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://connect.hyland.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 14:54:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/attempting-to-store-javascript-objects-to-process-variables/m-p/198572#M151702</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2014-12-05T14:54:29Z</dc:date>
    </item>
  </channel>
</rss>

