<?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: How can I execute JavaScript from Java code ? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78016#M24457</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried using the Alfresco SDK?&lt;/P&gt;&lt;P&gt;&lt;A class="jivelink1" href="https://ecmarchitect.com/alfresco-developer-series-tutorials/maven-sdk/tutorial/tutorial.html" title="https://ecmarchitect.com/alfresco-developer-series-tutorials/maven-sdk/tutorial/tutorial.html" rel="nofollow noopener noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/maven-sdk/tutorial/tutorial.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Mar 2018 20:18:24 GMT</pubDate>
    <dc:creator>douglascrp</dc:creator>
    <dc:date>2018-03-02T20:18:24Z</dc:date>
    <item>
      <title>How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78010#M24451</link>
      <description>Hello everyone,&amp;nbsp;I'm trying to execute some JavaScript code ( using Alfresco JavaScript API method ) from Java. Please if someone know how to do this.&amp;nbsp;Thanks in advance.</description>
      <pubDate>Mon, 19 Feb 2018 15:54:16 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78010#M24451</guid>
      <dc:creator>progm</dc:creator>
      <dc:date>2018-02-19T15:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78011#M24452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without more context the best I can do is suggest that you read the source. Specifically, take a look at&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;org/alfresco/repo/action/executer/ScriptActionExecuter.java to see how Alfresco leverages the ScriptService to run server side JavaScript such as when someone configures a folder rule to use "Execute Script".&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Depending on what you want to do you might also pick up a few tips by looking at&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;org/alfresco/repo/processor/ScriptServiceImpl.java.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Feb 2018 19:10:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78011#M24452</guid>
      <dc:creator>jpotts</dc:creator>
      <dc:date>2018-02-19T19:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78012#M24453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The script action should be the preferred way to call a JavaScript source file sitting on your classpath or stored in a node within the Repository. That way you can be sure that you could use that very same file also for rules or user-triggered actions. ScriptService is the low-level API for invoking JavaScript code and - apart from my attempts of writing a Nashorn based engine or running non-persistent, user-provided JavaScript code - I have so far not found any good reason to use that over the script action in any project.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 12:40:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78012#M24453</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2018-02-20T12:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78013#M24454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mr. &lt;STRONG&gt;Jeff&lt;/STRONG&gt; , Mr. &lt;STRONG&gt;Axel&lt;/STRONG&gt; thank you for the reply and the precise answer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did took a look at&amp;nbsp;those classes and did some research. I found this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #666600;"&gt;&lt;SPAN class="" style="color: #666600;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #666600;"&gt;&lt;SPAN class="" style="color: #666600;"&gt; // Create the script node reference&lt;BR /&gt; NodeRef script = this.nodeService.createNode(&lt;BR /&gt; this.folder,&lt;BR /&gt; ContentModel.ASSOC_CONTAINS,&lt;BR /&gt; QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testScript.js"),&lt;BR /&gt; ContentModel.TYPE_CONTENT).getChildRef();&lt;BR /&gt; this.nodeService.setProperty(script, ContentModel.PROP_NAME, "testScript.js");&lt;BR /&gt; ContentWriter contentWriter = this.contentService.getWriter(script, ContentModel.PROP_CONTENT, true);&lt;BR /&gt; contentWriter.setMimetype("text/plain");&lt;BR /&gt; contentWriter.setEncoding("UTF-8");&lt;BR /&gt; contentWriter.putContent("\"VALUE\";");&lt;BR /&gt; &lt;BR /&gt; // Create the action&lt;BR /&gt; Action action1 = this.actionService.createAction(ScriptActionExecuter.NAME);&lt;BR /&gt; action1.setParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF, script);&lt;BR /&gt; &lt;BR /&gt; // Execute the action&lt;BR /&gt; this.actionService.executeAction(action1, this.nodeRef);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #666600;"&gt;&lt;SPAN class="" style="color: #666600;"&gt;&lt;BR /&gt;&lt;STRONG&gt;Is it like that we can execute JavaScript from a Java class? If it is, how do I import "ScriptActionExecuter"&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG&gt;in my Java code that lets me executing the code above. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sorry if I misunderstood something, I'm new to this field.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks a lot.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2018 17:02:16 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78013#M24454</guid>
      <dc:creator>progm</dc:creator>
      <dc:date>2018-02-20T17:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78014#M24455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, there are many ways to do it, but that is one. You are basically leveraging the out-of-the-box script action. This is the same as if you had created a folder rule and selected "Execute Script" as the action, and then specified a JavaScript file that is sitting in the Data Dictionary/Scripts folder.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Mar 2018 17:22:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78014#M24455</guid>
      <dc:creator>jpotts</dc:creator>
      <dc:date>2018-03-01T17:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78015#M24456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Mr. &lt;A __default_attr="95631" __jive_macro_name="user" _jive_internal="true" data-id="95631" data-objecttype="3" data-type="person" href="https://community.alfresco.com/people/jpotts" rel="nofollow noopener noreferrer"&gt;&lt;/A&gt;‌ for your reply. But how to get this code works inside my Java class ? there is classes not defined, how do I import them all to my code and execute them. If you can please Mr. Jeff describe to me the steps. Thanks a lot.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2018 08:31:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78015#M24456</guid>
      <dc:creator>progm</dc:creator>
      <dc:date>2018-03-02T08:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78016#M24457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried using the Alfresco SDK?&lt;/P&gt;&lt;P&gt;&lt;A class="jivelink1" href="https://ecmarchitect.com/alfresco-developer-series-tutorials/maven-sdk/tutorial/tutorial.html" title="https://ecmarchitect.com/alfresco-developer-series-tutorials/maven-sdk/tutorial/tutorial.html" rel="nofollow noopener noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/maven-sdk/tutorial/tutorial.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2018 20:18:24 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78016#M24457</guid>
      <dc:creator>douglascrp</dc:creator>
      <dc:date>2018-03-02T20:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I execute JavaScript from Java code ?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78017#M24458</link>
      <description>&lt;P&gt;Hey&lt;/P&gt;&lt;P&gt;Create a file with hello.js&lt;/P&gt;&lt;P&gt;Write and save the code in the file&lt;/P&gt;&lt;P&gt;Open terminal&lt;/P&gt;&lt;P&gt;Write command jjs hello.js and press enter&lt;/P&gt;&lt;P&gt;After procedure you will find output.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 12:34:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-can-i-execute-javascript-from-java-code/m-p/78017#M24458</guid>
      <dc:creator>hannahkhisty</dc:creator>
      <dc:date>2021-03-02T12:34:45Z</dc:date>
    </item>
  </channel>
</rss>

