Creating a custom widget in project websynergy
By siddeshk123 on May 16, 2008
Courtesy : Thanks to Neel from the Portal team to give me a heads up on this.
Goal : To create a custom widget in the Project websynergy codebase and deploy it in the websynergy portal. Project Websynergy is Sun's next generation portal using Liferay Portal Server, GlassFish v3, and MySQL . I am re-using a JSR 286 portlet which my colleague Sriram has written and can be found here : http://portalpack.netbeans.org/tutorials/eventing/EventingStoryBoardTutorial.html
Creating a EmployeeInfo Portlet and a Health Portlet which displays the BMI of the person entered in EmployeeInfo Portlet.
Steps to create the widget in websynergy :
Steps to checkout the websynergy code base : http://blogs.sun.com/siddeshkamath/entry/writing_a_custom_portlet_under
1. Once the code base is checked out, cd to synergy/widgets directory
2. run ant create . Enter the widget name as "EmployeeInfo" , Enter the widget directory as "EmployeeInfo"
3. The widget directory will have the "EmployeeInfo" directory created which will have src, web and build.xml
4. copy the Employee.java and EmployeeInfo.java under synergy\\widgets\\EmployeeInfo\\src\\java\\com\\sun\\portlet
5. change the package name in Employee.java and EmployeeInfo.java for ex : to "package com.sun.portlet"
6. The EmployeeInfo directory will have "web" directory -> EmployeeInfo-docroot, META-INF and WEB-INF
7. copy the jsp files to WEB-INF/jsp directory
8. add the following lines in the individual jsp files
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
9. The purpose of liferay-display.xml and liferay-portlet.xml
a. liferay-portlet.xml is like a wrapper on the portlet.xml. Liferay has added certain extra functionalities and they have used their own dtd (liferay-portlet-app_5_0_0.dtd)
b. The liferay-display.xml has the following items :
The category.sample means that when we deploy this portlet and then log in as paul/paul or any other user, then click on "Add application" link, the EmployeeInfo portlet will be displayed under "sample"
10. Add the portlet name in the build.xml in the widgets directory
11. The war file will be created under the directory synergy\\widgets\\EmployeeInfo\\build\\war
12. copy this war file and just paste it under the directory C:\\Documents and Settings\\<username>\\liferay\\deploy
Here is how the portlets look on the websynergy :