Liferay is an Open Source Portal Written in java Language and Distributed under GNU Lesser General Public License and proprietary licenses. Liferay allows you to customize it according to your needs.
Saturday, July 26, 2014
Liferay Hello World Portlet | How To Create Portlet Using Liferay Plugins SDK?
In this post we will create and deploy a simple "hello world" portlet using the Liferay Plugins SDK using step by step guide as follows.
Initial Setup
- Install Java Development Kit JDK 1.5 or higher, and set JAVA_HOME environment variable point to installation home directory of JDK, (Click here to know how to setup environment variable on different operating systems like windows / Unix / Linux platforms)
- For Windows, right click on My Computer -> Properties -> Advanced -> Environment Variables here you can add or edit windows environment variables e.g. if JDK is installed at "c:\program files\java\jdk1.6" then set JAVA_HOME to "c:\program files\java\jdk1.6"
- For Unix or Linux platforms go to home directory of user and add entry to set variable and export it in hidden file named .profile
For example,JAVA_HOME=/usr/lib/java/java-1.6 export JAVA_HOME
- Add JAVA_HOME/bin directory to PATH environment variable. i.e. for windows set value of PATH to %JAVA_HOME%\bin;%PATH% and for Unix and Linux platforms set its value to $JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
- Install ANT 1.7 or higher and set ANT_HOME environment variable value to ANT installation directory.
- Install Liferay portal with you choice of Application server (Click here for guideline to setup liferay portal and different platforms and application servers)
- Install Liferay Plugin SDK (Visit here to know guideline to install Liferay plugins SDK)
./create.sh hello-word "Hello World"
For all windows platforms:create.bat hello-word "Hello World"
You should get a BUILD SUCCESSFUL message from Ant, and there will now be a new folder inside of the portlets folder in your Plugins SDK. This folder is your new portlet project. This is where you will be implementing your own functionality. Notice that the Plugins SDK automatically appends “-portlet” to the project name when creating this folder. In this case you can find directory "hello-word-portlet" in side portlets directory Deploying the portlet on Liferay Portal- Make sure your Liferay Portal is already running or else you can start it by starting containing application server.
- To deploy open a terminal window in your portlets/hello-world-portlet directory and enter this command
ant deploy
You should get a BUILD SUCCESSFUL message, which means that your portlet is now being deployed. If you switch to the terminal window running Liferay, and wait for a few seconds, you should see the message “1 portlet for my-greeting-portlet is available for use.” If not, something is wrong and you should double check your configuration.
- Add JAVA_HOME/bin directory to PATH environment variable. i.e. for windows set value of PATH to %JAVA_HOME%\bin;%PATH% and for Unix and Linux platforms set its value to $JAVA_HOME/bin:$PATH
Select the Sample category, and then click Add next to Hello World. Your portlet should appear in the page below. Congratulations, you've just created your first portlet!
Subscribe to:
Posts (Atom)