Liferay-Developer-Guide-6.0-Old-6.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 Table of Contents CONVENTIONS.............................................................................................................................................. 6 PUBLISHER NOTES......................................................................................................................................... 7 UPDATES.....................................................................................................................................................7 November 3rd 2010....................................................................................................................... 7 February 27th 2011....................................................................................................................... 7 March 9th 2011.............................................................................................................................. 7 March 31st..................................................................................................................................... 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............................................................................37 4. Creating Liferay Themes...............................................................................................39 INTRODUCTION........................................................................................................................................... 39 CREATING A THEME..................................................................................................................................... 40 Deploying the Theme................................................................................................................. 40 ANATOMY OF A THEME................................................................................................................................ 40 THUMBNAILS..............................................................................................................................................42 JAVASCRIPT............................................................................................................................................... 42 SETTINGS.................................................................................................................................................. 43 COLOR SCHEMES......................................................................................................................................... 44 PORTAL PREDEFINED SETTINGS.......................................................................................................................45 THEME INHERITANCE.................................................................................................................................... 46 5. Hooks........................................................................................................................... 49 CREATING A HOOK...................................................................................................................................... 49 Deploying the Hook.................................................................................................................... 49 OVERRIDING A JSP..................................................................................................................................... 50 Customizing JSPs without overriding the original................................................................ 50 PERFORMING A CUSTOM ACTION.................................................................................................................... 51 Extending and Overriding portal.properties..........................................................................52 iii OVERRIDING A PORTAL SERVICE..................................................................................................................... 52 OVERRIDING A LANGUAGE.PROPERTIES FILE....................................................................................................... 54 6. Ext plugins....................................................................................................................55 CREATING AN EXT PLUGIN............................................................................................................................. 56 DEVELOPING AN EXT PLUGIN..........................................................................................................................58 Set up............................................................................................................................................ 58 Initial deployment...................................................................................................................... 59 Redeployment............................................................................................................................. 61 Advanced customization techniques.......................................................................................62