Search This Blog

Saturday, October 13, 2012

Adding JSR 286 portlets to Liferay

Today I am going to add a series of portlets to Liferay Social Office that allow users to wire events using events in one portlet and others. I want to have 3 portlets. First is a tree portlet that has a list of items that are essentially locations of factories for a business. The second portlet will be a google map showing the location of the factory. The third portlet will show the weather and news related to the factory.

Steps to create the first portlet.

1. I installed the Liferay Social Community Edition on my machine by simply downloading latest binary from Liferay website. I wanted the one that ships with Tomcat. Its available at Sourceforge

2. I downloaded and installed the Liferay Plugins SDK on my machine. Let us cd to that directory
cd ${sdk.directory}

3. Within the Liferay Plugins SDK, I copied the build.properties to build.${my.name}.properties where ${my.name} is My name (This should be the name of the logged in user on the machine).

4. I edited the build.${my.name}.properties file to add the following lines

app.server.type=tomcat
app.server.dir=/home/${my.name}/work/tools/java/liferay/liferay-social-office-1.5b/tomcat-6.0.18
app.server.deploy.dir=${app.server.dir}/webapps
app.server.lib.global.dir=${app.server.dir}/lib/ext
app.server.portal.dir=${app.server.dir}/webapps/ROOT

5. Now to create the placeholder for my first portlet on the Social Office website. First we cd to the portlets directory

cd ${sdk.directory}/portlets
ant -Dportlet.name=navigator -Dportlet.display.name="Location Navigator" create


6. This creates a basic portlet in the dev folder. We will now modify the content to add our Navigator code. I want to add a jQuery Accordion control so that we can go to one factory location at a time.

I edit view.jsp and add the following code


6. The above step creates the portlets in the ${sdk.directory}/portlets directory. We still need to deploy it within our social office environment. We do that by typing the following command.

No comments: