/* InfoAxon GA Code */
Bootstrap Essentials
September 23, 2015 – 8:50 am | No Comment

Admittedly an august fervor for the publication and launch of my new book – Bootstrap Essentials.
No magnitude of thankfulness would be adequate to the Packtpub team and to my colleagues at InfoAxon.
Here are the links …

Read the full story »
Home » Open Source Tutorials

Tutorial: Building Alfresco web scripts, deploying as Liferay Portlets – Part 4

Submitted bySnig Bhaumik on October 4, 2009 – 5:50 am5 Comments

Deploying the Web Scripts as Liferay Portlets

Well, we now are able to create and build web scripts both by Java and by JavaScript.
Now, we want our web scripts to be displayed in Liferay portal as portlets.

For that, we need to update the following xml files in order to register the alfresco web scripts in Liferay portlet list. These files are in C:\mystackroot\webapps\alfresco\WEB-INFfolder.

For deploying the Alfresco web scripts in Liferay, you need to add the information of the web script (as portlet) in 4 XML files, restart your server, and Whoa – you are done.

  • Register the Web Script as a servlet.
  • Register the Servlet mapping.
 Mirrors dvd
  • In this way, register all the web scripts as servlets to be deployed as Liferay portlets.
  • portlet.xml

    Register the web scripts as portlets

    <value>/alfresco/168s/infoaxon/repository/ myfirstscript</value>
    <title>My First Web Script</title>
    <short-title>My First Web Script</short-title>

    Few points to be noted here:

    1. portlet-name should match the web script name
    2. scriptURL should be like /alfresco/168s/<<web-script-url-as-defined-description-xml>>

    In this way, register all the web scripts to be deployed as Liferay portlets.


    Define the web scripts as portlets

    • The portlet-name must be same as defined in portlet.xml file.
    • In this way, define all the web scripts to be deployed as Liferay portlets.

    Describe how the portlets will be displayed in Liferay portlet list
    <portlet id=”myfirstscript”></portlet>

    The portlet id should match the portlet-name defined earlier.
    You can define your own category in which you would like see your portlets in Liferay.

    <category name="My Custom Portlets">
    <portlet id="myfirstscript"></portlet>
    <portlet id="helloworld"></portlet>

    In this way, define all the web scripts to be deployed as Liferay portlets.

    Congrats, All Done!!!
    • Restart your server.
    • Navigate to Liferay and login as a user with suitable permissions to add a portlet is a page.
    • Open the Add Application popup in liferay. You should see My Custom Portlets category in the list and the portlets you have just registered under it.
    • Drag your portlet in the page and enjoy!

    About The Author

    Snig Bhaumik

    Mr. Snigdhendu Bikas Bhaumik is the Technical Director and Heads the Research and Development for InfoAxon. As an Open Source enthusiast, Snig is an active contributor of several open source communities such as - Alfresco ECM (Author of Alfresco Calendar components now included and distributed in Alfresco version 3.0), Liferay Portal and Pentaho Business Intelligence Suite. Snig has just completed a book on Alfresco published by Packtpub - http://www.packtpub.com/alfresco-3-cookbook/book. Snig specializes in Knowledge Management and Business Intelligence domains, and responsible for designing and architecting InfoAxon’s KM and BI solution offerings. He holds an enriching experience of around 12 years in designing, architecting and developing various solutions on open source technologies. Follow him on twitter - @snigbb.


    • [...] Web Scripts as Portlets tutorials, how to deploy Alfresco Web Scripts as Liferay Portlets have been discussed. In this [...]

    • nikolai says:

      Hello everybody,

      I have a Tomcat server with a Liferay Portal (6.0.5) and Alfresco (v3.4c). I followed some tutorials to have webscripts as portlets, and everything seems to work well with out-of-the-box UI portlet.

      But, I have a problem with my own webscripts, especially when I have:
      - a webscript with a form

      Code: Select all

      Name :
      File :

      - a webscript with the formdata object to catch informations from the previous webscript

      Code: Select all
      var filename = null;
      var content = null;
      var title = “”;

      // locate file attributes
      for each (field in formdata.fields)
      if (field.name == “name”)
      title = field.value;
      else if (field.name == “myfile” && field.isFile)
      filename = field.filename;
      content = field.content;
      // treatment….

      My problems:
      - When I press the submit button, I leave the portal. I found a solution with the scripturl() method

      Code: Select all

      - But POST webscripts don’t seem to be supported by the WebScriptPortlet class. A first solution was to bring together the both webscripts.

      Code: Select all

      Code: Select all
      if (args.step == 1)
      //treatment with the formdata object
      //treatment to build the form
      - But now, I have this exception when I submit the form: Exception: org.mozilla.javascript.EcmaError – ReferenceError: “formdata” is not defined (AlfrescoScript#10)

      Is there an issue with POST webscripts in portlet? Is there a solution to my problem?

      Thank you, and excuse me for my english

    • Snig Bhaumik says:

      Hi Nikolai

      I am assuming you are invoking the 2nd web script as the post action of the form in your 1st web script.
      In addition to that, the form in your 1st web script should have some special attributes such as
      method="post" enctype="multipart/form-data"

      Thus form tag would look like
      <form id="frmUploadDoc" method="post" enctype="multipart/form-data" accept-charset="utf-8" action="/alfresco/service/.....">

      I understand your problem that you are being redirected from the portal while submitting the form. For that I normally open a little new browser window and force my form (from 1st web script) to submit to the new window.
      Adding this, the form tag will be
      <form id="frmUploadDoc" target="newwin" method="post" enctype="multipart/form-data" accept-charset="utf-8" action="/alfresco/service/.....">

      Hope this helps.


    • Carlo says:

      Hi i’m trying to use a webscript as portlet, using your guide. But i can’t understand, how liferay, can comunicate with Alfresco,

      i have Liferay 6.1 on a Machine, and Alfresco 3.4 on an other machine… i think that Liferay need and Url to get the webscript/portlet..

      Can you explain this point?

      thank you..!!

    • Snig Bhaumik says:

      Hi Carlo

      The first pre-requisite of this model is that Liferay and Alfresco should be deployed in a single App Server, needless to say in a single machine. Similar in case of clustered setup also.

      However, if your deployment is having two different machines, then you have to use something like WSRP portlets in Liferay. The above approach won’t work.

      Hope this helps.

    Leave a comment!

    Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

    Be nice. Keep it clean. Stay on topic. No spam.

    You can use these tags:
    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.