Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As was pointed out, you may want to start by using JavaScript instead of Java. Also, I'm noticing that you are creating a new JSON object in your code, but I'm not sure why.</p> <p>For example, using JavaScript, a web script that accepts the name of a folder to be created under company home might have a controller that would look like this:</p> <pre><code> function main() { var folderName = args.folderName; if (folderName != null &amp;&amp; folderName != "") { // continue } else { status.setCode(500); status.setMessage("Missing folder name argument"); status.setRedirect(true); return; } var createdFolder = companyhome.createFolder(folderName); model.createdFolder = createdFolder; } main(); </code></pre> <p>The code looks for an argument passed to it called folderName and then uses the built-in "companyhome" root scoped variable to create the new folder. It then passes the newly-created folder node to the model so that some data about the new node can be echoed back to the user.</p> <p>The name of the JavaScript controller (shown above) is createFolder.post.js. I checked it in to the repository under Data Dictionary/Web Scripts/example. Along with that, I checked in a file called createFolder.post.desc.xml, which is the web script descriptor:</p> <pre><code> &lt;webscript&gt; &lt;shortname&gt;Create folder example&lt;/shortname&gt; &lt;description&gt; &lt;![CDATA[ Creates a new folder in Company Home using the name specified in the folderName argument. ]]&gt; &lt;/description&gt; &lt;url&gt;/example/createFolder?folderName={folderName}&lt;/url&gt; &lt;format default="html"&gt;argument&lt;/format&gt; &lt;authentication&gt;user&lt;/authentication&gt; &lt;transaction&gt;required&lt;/transaction&gt; &lt;family&gt;Example&lt;/family&gt; &lt;/webscript&gt; </code></pre> <p>And a file called createFolder.post.html.ftl, which is the HTML version of the web script view:</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;Create folder web script&lt;/title&gt; &lt;/head&gt; &lt;body&gt; Successfully created a folder with the following metadata:&lt;br /&gt; Name: ${createdFolder.name}&lt;br /&gt; ID: ${createdFolder.id}&lt;br /&gt; Noderef: ${createdFolder.nodeRef}&lt;br /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Once checked in, I refreshed the web script index by going to <a href="http://localhost:8080/alfresco/s/index" rel="nofollow">http://localhost:8080/alfresco/s/index</a> and clicking the "refresh web scripts" button.</p> <p>I then invoked the web script using CuRL, like this:</p> <pre><code> curl -uadmin:admin -X POST "http://localhost:8080/alfresco/s/example/createFolder?folderName=foobar" </code></pre> <p>You'll notice that I chose to make my web script accept POSTs. If you wanted to use a different HTTP method, you'd simply change the file names accordingly.</p> <p>Jeff</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload