Liferay Portal is a fantastic product for building a web site. It’s incredibly robust and feature-filled, and this book is designed to help Java EE developers learn to use the platform effectively. It doesn’t exhaustively go through every API Liferay has; you are better served by looking at online reference documentation for that. Instead, this book is like a roadmap of practical experience in working with the Liferay platform. I’ve tried to make the book useful to anyone working with Liferay, from the absolute beginner who wants to read the book from cover to cover, to the experienced Java EE developer who wants to dive into subjects of interest.
In order to do this, I’ve created an example company whose web site we’ll work on together throughout the book. The code examples are purposefully designed to hit many of the most-needed Liferay features and APIs that you’ll want to use in your own work, but they stand on their own. Experienced developers should be able to jump in and work with the examples in any order you like.
If you’re familiar with Java web development, this book is for you. You don’t need to have any prior experience with portals or Liferay; in fact, I’d prefer that you didn’t. That way, you can approach the material with a fresh view of portals and Liferay in particular. But because this is an In Action book, we hit the ground running really fast; if you need an introduction to the Portlet API, you may want to read appendix B in between chapter 2 and chapter 3.
If you’ve done work with other portals before, this book will help you become familiar with Liferay and all it has to offer. Your knowledge of the Portlet API will help you understand the underpinnings of Liferay’s platform, and you’ll learn how to make use of lots of Liferay-specific APIs that enhance and complement it.
Seasoned Liferay developers will also be served well by this book. Liferay 6.0 and 6.1 introduce many architectural changes that affect developers, and many best practices from previous versions change in more recent releases. You’ll also get to see how to work with some of Liferay’s newer APIs, such as workflow, in this book.
Naturally, you’ll get the most complete view of Liferay development if you read this book from cover to cover. The book has been designed to build on itself, and you’ll certainly be well-served by doing that. I do recognize, however, that this is not the way many people approach books like this, so the book has also been designed to allow you to flip through it, find what you’re looking for, and apply that information to your own project. I’ve done this by grouping the chapters into three parts.
Part 1, which includes chapters 1 and 2, contains introductory material about Liferay and Liferay development. Part 2, which includes chapters 3–7, is all about writing applications on Liferay’s platform. To round out the discussion of Liferay development, part 3 (chapters 8–10) describes how to customize Liferay to conform to the requirements of your project. Let’s take a look at how this works out in detail by viewing a high-level roadmap of the book.
Chapter 1 gets things started quickly by talking about Liferay and how it fulfills the missed promises of the portal platform. You’ll get an introduction to what Liferay is, how it structures a web site, how to navigate in Liferay, and how to design a Liferay implementation project.
Chapter 2 picks up from there and dives right in to setting up a development environment and writing your first portlet. This portlet uses just the generic Portlet API, so you can get your feet wet with framework that underlies Liferay.
In chapter 3, you begin using Liferay’s development platform, starting with Service Builder. You’ll use Service Builder to design and create a data-driven application from a single configuration file.
Moving from the back end to the front end, chapter 4 continues from where we left off in chapter 3. You use the MVC design pattern provided by Liferay’s MVCPortlet to create the portlet application that depends on the service layer you generated previously. You also start using Liferay’s AlloyUI tag libraries to lay out the forms required by the application.
In chapter 5, we take a break from applications and look at Liferay themes. Themes let you completely customize the way Liferay looks, so that your web site can have the look and design that you define. This chapter will prepare front-end developers for working their design magic with Liferay.
We move out of themes and back to Liferay APIs with chapter 6. Here, you learn about Liferay’s Social API, so that you can enable users to connect with each other and view their activities on your site. You’ll also see how Liferay integrates with existing social networks.
Chapter 7 continues with a focus on the user by looking at Liferay’s Collaboration API. In this chapter, you create a new portlet that provides a platform on which users can collaborate: a slogan contest. You’ll learn how to create Liferay assets, to use Liferay’s Workflow API, to tag and categorize your content, to add discussions and ratings, and to use custom SQL queries in Liferay applications.
From here, we leave the realm of Liferay applications and begin looking at customizing Liferay in chapter 8. This chapter shows you hook plugins, and how hooks can be used to customize properties, JSP files, and services. You use a hook to modify Liferay’s Shopping portlet and give it a custom user interface.
We put Liferay customization on steroids with chapter 9. Here, you use Ext plugins to customize anything in Liferay. As far as Liferay’s development framework goes, this is the ultimate in what you can do to make Liferay your own. We round out this discussion by talking about development best practices, so you know when it’s appropriate to use each kind of plugin.
Now that you know all the components of Liferay development, chapter 10 ends the book by showing you seven APIs in Liferay that you can use in various places in your applications. You’ll see how to create friendly URLs, use ActionCommands for larger applications, use indexing and search, and more.
Code conventions in the book follow the style of other Manning books in this series. Code always appears in a monospaced font like this. Additionally, at times it will be annotated with descriptive numbers or bolded in order to call out particularly interesting examples. You’ll also see class names and other code terms in the text using the same monospaced font. Italics are used for emphasis. After each code listing, we include the path and filename for that particular piece of code.
Liferay uses particularly descriptive package names, class names, and JSP tags, and these can get pretty long. This is fine when you’re looking at code on a screen, but these names don’t always translate well to a book. For that reason, I’ve had to break up some lines in the book that aren’t broken in the code. When this happens, you’ll see a line-continuation character (
). This means the code is meant to be on a single line, but for layout purposes it wouldn’t fit unless we made the font really small—so small you couldn’t read it, which sort of defeats the purpose of printing it in the first place.
One other thing must be mentioned about the code: there’s a lot more of it than appears in the book. In the text, I’ve pointed out only the important code, and left the mundane, obvious stuff as a download only. If I showed everything, the book would be really boring, and you wouldn’t want to read it. If you want to look at the complete examples, please download the code. You can find it at Manning’s web site at www.manning.com/LiferayinAction or at my profile on liferay.com at www.liferay.com/web/richard.sezov/documents.
One of Liferay’s strengths is that it comes from an agnostic philosophy with regard to the environment in which it runs. This means you’re free to choose whichever environment you like to work in the most. Because it’s Java, of course, JDK 5+ must be able to run on your machine. Further details about this appear in chapter 2, where you install a Liferay development environment. Even more details appear in appendix A, where I show you how to get set up in multiple IDEs.
Because Liferay supports so many deployment combinations, you also have a huge choice of what database or application server you want to use. For simplicity’s sake, for the book I used the development configuration that Liferay developers use the most: a Tomcat runtime and a MySQL database. Liferay conveniently supplies a Liferay/Tomcat bundle as a download, so you don’t have to worry about installing Liferay yourself into a Java application server. Of course, you’re free to use any of Liferay’s deployment combinations, but I think this one is the best for developers. It’s small, fast, lightweight, and easily configured.
Purchase of Liferay in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/LiferayinAction. This page provides information on how to get on the forum once you're registered, what kind of help is available, and the rules of conduct on the forum.
Manning’s commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the Author Online forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest his interest stray!
The Author Online forum and the archives of previous discussions will be accessible from the publisher’s web site as long as the book is in print.
Rich Sezov, Jr is an unusual combination of software developer, writer, and trainer. Most of his career has been spent doing software development, but as Liferay’s Knowledge Manager, he now has the opportunity to help others do the same by writing about it and teaching it. And man, does he love Liferay. When Rich isn’t working, you’ll generally find him spending time with his wife and daughter, doing all kinds of interesting things, and (he hopes) not getting into too much trouble.