Handle Websript Request Parameters in Alfresco

Alfreso supports RESTFul websript which provides a very powerful and convenient way to integrate Alfresco repository to other applications or tools. It is powerful and flexible, yet secure.

If you are looking for how to get started with Websript or what websript are I suggest you to first refer to these posts on those topics. Here we are just going concentrate on how to deal with request parameters in alfresco websript. This is very significant and essential part when you are extensively dealing with websript because you always come across a case where you want to pass in few parameters to websript to and expects it to execute internal business logic based on those parameters.

Without further ado let us start exploring that.

  • Request parameter in javasript based GET websript

In GET HTTP method we pass parameter as a part of url only. First we define parameters in Websript description file as follow.



  <description>Testing Parameters</description>

  <url>/test/ {param}</url>

  <format default="html">argument</format>



Then access parameters in javasript controller as follow.

var paramvalue=url.extension;

  • Request parameter in javasript based POST websript

In case of POST HTTP method we pass parameters as part of request body. Most convenient way of passing multiple parameters is in json format. Here is the sample json request body content.

You need not to add any parameters in description file.

Sample json request body content

{parentnode:”workspace://spaestore/sfsfsdsdfsdffsfds”,” childs”:[{“node”:”value1”},{“node”:”value2”}]}

Here is the way to retrieve those parameters.



var parent=json.get("parentnode");

var childarray=json.getJSONArray("childs");

var pnode=search.findNode(parent);


  • Request parameters in JAVA based websript

In case we have java lass as backend controller we have Websript request objet available with us which contains those request parameters. We can retrieve those parameters as follow.

Description file includes details about parameters which should be passed



  <description>Testing Parameters</description>


  <format default="html">argument</format>



This is how we retrieve it in java class

String tempvariable=requestObject.getParameter(“parametername”);

Note: In case of POST also we will be using same way to retrieve the json objet which is being passed in request body. Make sure name of json objet passed math with request parameter name.

Summary: Websript follows REST standards and it is very popular tool for integrating Alfreso. So, I hope this will help alfresco developers to deal with complex websript implementations. Stay tuned for more such articles.

Further Reading:



Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight


I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *