Liferay-Developer-Guide-6.0.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Liferay Developer's Guide Liferay Developer's Guide Connor McKay, Editor Jorge Ferrer, Editor Copyright © 2011 by Liferay, Inc. This work is offered under the Creative Commons Attribution-Share Alike Unported license. You are free: ● to share—to copy, distribute, and transmit the work ● to remix—to adapt the work Under the following conditions: ● Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). ● Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. The full version of this license appears in the appendix of this book, or you may view it online here: http://creativecommons.org/licenses/by-sa/3.0 Contributors: Joseph Shum, Alexander Chow, Redmond Mar, Ed Shin, Rich Sezov, Samuel Kong, Connor McKay, Jorge Ferrer, Julio Camarero, Daniel Sanz, Juan Fernández, Sergio González, Miguel Pastor, Jim Hinkey, Greg Amerson Table of Contents CONVENTIONS...........................................................................................................................................6 PUBLISHER NOTES.....................................................................................................................................7 UPDATES...................................................................................................................................................7 November 3rd 2010.......................................................................................................................7 February 27th 2011.......................................................................................................................7 March 9th 2011..............................................................................................................................7 April 7th 2011................................................................................................................................8 April 29th 2011..............................................................................................................................8 October 11th 2011.........................................................................................................................8 1. Introduction...................................................................................................................9 DEVELOPING APPLICATIONS FOR LIFERAY....................................................................................................9 Portlets.........................................................................................................................................10 OpenSocial Gadgets....................................................................................................................10 Reusing existing web applications...........................................................................................11 Supported Technologies............................................................................................................12 EXTENDING AND CUSTOMIZING LIFERAY...................................................................................................13 Customizing the look and feel: Themes...................................................................................13 Adding new predefined page layouts: Layout Templates.....................................................13 Customizing or extending the out of the box functionalities: Hook plugins....................13 Advanced customization: Ext plugins.....................................................................................14 CHOOSING THE BEST TOOL FOR THE JOB.....................................................................................................14 2. The Plugins SDK...........................................................................................................17 INITIAL SETUP.........................................................................................................................................17 Ant Configuration.......................................................................................................................18 Plugins SDK Configuration........................................................................................................19 STRUCTURE OF THE SDK.........................................................................................................................19 3. Portlet Development.....................................................................................................21 CREATING A PORTLET..............................................................................................................................21 Deploying the Portlet.................................................................................................................22 ANATOMY OF A PORTLET.........................................................................................................................23 A Closer Look at the My Greeting Portlet................................................................................24 WRITING THE MY GREETING PORTLET.....................................................................................................27 UNDERSTANDING THE TWO PHASES OF PORTLET EXECUTION.....................................................................29 PASSING INFORMATION FROM THE ACTION PHASE TO THE RENDER PHASE.................................................33 DEVELOPING A PORTLET WITH MULTIPLE ACTIONS...................................................................................36 OPTIONAL: ADDING FRIENDLY URL MAPPING TO THE PORTLET................................................................38 4. Creating Liferay Themes...............................................................................................41 INTRODUCTION........................................................................................................................................41 CREATING A THEME.................................................................................................................................42 Deploying the Theme.................................................................................................................42 ANATOMY OF A THEME............................................................................................................................42 THUMBNAILS...........................................................................................................................................44 JAVASCRIPT............................................................................................................................................44 SETTINGS................................................................................................................................................45 COLOR SCHEMES......................................................................................................................................46 PORTAL PREDEFINED SETTINGS................................................................................................................47 THEME INHERITANCE...............................................................................................................................48 5. Hooks...........................................................................................................................51 CREATING A HOOK...................................................................................................................................51 Deploying the Hook....................................................................................................................51 OVERRIDING A JSP..................................................................................................................................52 Customizing JSPs without overriding the original................................................................52 iii PERFORMING A CUSTOM ACTION..............................................................................................................53 Extending and Overriding portal.properties..........................................................................54 OVERRIDING A PORTAL SERVICE...............................................................................................................54 OVERRIDING A LANGUAGE.PROPERTIES FILE..............................................................................................56 6. Ext plugins....................................................................................................................57 CREATING AN EXT PLUGIN.......................................................................................................................58 DEVELOPING AN EXT PLUGIN....................................................................................................................60 Set up............................................................................................................................................60 Initial deployment......................................................................................................................61 Redeployment.............................................................................................................................63 Advanced customization techniques.......................................................................................64