Sunday, September 28, 2008

Tutorial: Building Alfresco web scripts, deploying as Liferay Portlets - Part 1

Web Script Architecture

A Web Script is simply a service bound to a URI which responds to HTTP methods such as GET, POST, PUT and DELETE; which also can be deployed as a JSR portlet is any standard and compatible container.

The basic components of a Web Script are
  1. Declaration XML File.
  2. Presentation Freemarker Template.
  3. Implementation JavaScript and/or Java Code segments, technically optional.
For example, here are three files created for implementing a Web Script, named (everybody's favorite) helloworld.




The XML file defines the URI and other behaviors of the web script.
The Freemarker (FTL) file constructs final contents returned by the web script.
The JavaScript (JS) file builds the business rules implementations for the web script.

You can return a variety of different data from the web script, by defining different FTL templates. In our example, we have defined only one output type - HTML, since we have created one FTL file - helloworld.get.html.ftl. Similarly define other templates to return other data structures such as
  • text => text/plain
  • xml => text/xml
  • atom => application/atom+xml
  • rss => application/rss+xml
  • json => application/json
The JS file is a plain JavaScript file written using JavaScript APIs.

The business layer of the Web Script can be developed either or both in JavaScript and Java. In this tutorial, we would discuss both the approaches and how to deploy the web script as a JSR-168 portlet in Liferay.

In the next installment of this tutorial, we will discuss about how we can create a simple helloworld web script using javascript.

Saturday, September 20, 2008

Tutorial: Building Alfresco Web Scripts, deploying as Liferay Portlets - Introduction

Today, in ever-growing world of Knowledge Management Alfresco has established itself as the most competent Open Source alternative.

In addition of being Open Source and its flexible licensing model (GPL), its dynamic design and extensibility makes it one of the most palpable choices in this domain today.

As it says
  • 5 Times Faster than Traditional Closed Systems
  • 10 Times Cheaper than Traditional Closed Systems
One of its smart innovation is the Web Scripts. A few cool features are offered by this model:
  • Web Scripts are by default exposed as REST services which can return data in various formats like HTML, XML, ATOM, JSON
  • Web Scripts, after a little pain, can be deployed as JSR portlets in any JSR container
Thus, this makes a commendable choice to develop applications over Alfresco.

This set of posts discusses how Web Scripts can be developed in Alfresco, and deployed in a JSR container such as Liferay.

However, this does assume that you have knowledge about Alfresco Web Scripts, Liferay Portal and a brief knowledge on their architecture. This also assumes you have already deployed Alfresco in Liferay context.