官术网_书友最值得收藏!

Adding arguments to a web script

Let's say we want to modify our first web script to display the name too in the web script response, for example, Hello! Ramesh. It can be done in a simple way by passing the name as the URL argument of the web script and then using this argument to generate the response in the FreeMarker template. In order to do this, we will have to perform the following steps:

  1. Log in to Alfresco Share UI.
  2. Click on the Repository link from the top header.
  3. Edit the descriptor file helloworld.get.desc.xml at Data Dictionary | Web Scripts Extension location as follows:
    <webscript>
      <shortname>Hello World</shortname>
      <description>First webscript Hello world</description>
      <url>/helloworld?name={argumentName}</url>
    </webscript>
  4. Edit the FreeMarker template helloworld.get.html.ftl at Data Dictionary | Web Scripts Extension as follows:
    <html>
      <body>
        <p>Hello! ${args.name}.</p>
      </body>
    </html>
  5. Register the web script by hitting http://localhost:8080/alfresco/service/index and click on the Refresh Web Scripts button.
  6. Now, hit the URL http://localhost:8080/alfresco/service/helloworld?name=Ramesh in order to execute the web script. On execution, you should be able to see Hello! Ramesh. as the output.

Note

It is important to understand here that even if you had not provided name={argumentName} in the third step and hit the URL to execute the web script, as mentioned in the sixth step, then you would also have got the same result. Specifying name={argumentName} in the description document helps you know about the arguments used by web script. This way, by just looking at the description document, you will know about the arguments for web script. As a good practice, you should always add the arguments used by your web script in its description document.

主站蜘蛛池模板: 民县| 信丰县| 淮安市| 诸暨市| 平凉市| 望谟县| 竹北市| 南昌县| 环江| 习水县| 中牟县| 乌拉特后旗| 江源县| 建水县| 长垣县| 淮北市| 凤庆县| 舟山市| 方城县| 英吉沙县| 横峰县| 庆阳市| 津市市| 方正县| 澄城县| 清镇市| 灌云县| 惠来县| 揭东县| 柳州市| 富宁县| 鹿泉市| 项城市| 华亭县| 寻乌县| 阜新市| 禄劝| 双鸭山市| 九龙城区| 金平| 区。|