Subscribe

Liferay Hello World Portlet | How To Create Portlet Using Liferay Plugins SDK?


Share |

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
Steps for creating portlet using Liferay Plugins SDK
Creating portlets with the Plugins SDK is extremely simple. There is a portlets folder inside of the Plugins SDK folder. This is where your portlet projects will reside. To create a new portlet, first decide what its name is going to be. You need both a project name (without spaces) and a display name (which can have spaces).
When you have decided on your portlet's name, you are ready to create the project. For the greeting portlet, the project name is “hello-word”, and the portlet title is “Hello World”. Navigate to the portlets directory in the terminal and enter the following command

For Linux, Unix and Mac OS X:
./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.
Go to your web browser and log in to the portal as explained earlier. Then mouse over Add at the top of the page, and click on More.
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!





Share |

No comments yet

Hot Topics

My Headlines