Appendix B. Introduction to the Portlet API

 

To help you understand the foundation undergirding Liferay’s platform and get started writing portlets according to the Java Portlet Standard, this appendix takes a closer look at the Portlet API. Because many reading this book may have never worked with portlets before, I want to make sure that I at least give you a quick and dirty introduction to the portlet specification to show how it differs from the servlet specification. Of course, this discussion didn’t fit well into the book, so it’s here. For a more in-depth view of the Portlet API, see Portlets in Action by Ashish Sarin (Manning, 2011).

B.1. Portlets as fragments of a web page

Portlets are web applications that run in a portion of a web page. Rather than being responsible for (and taking up) the whole page, they’re instead responsible only for their own functionality. If you were expecting me to say something more profound or mysterious, I’m sorry to disappoint you: that’s all they are. But this gains you a lot.

As a developer, you’re free to concentrate only on your application and its functionality, and you don’t have to worry about ancillary things like users, user management, registration, layout, permissions, and the like. That stuff is built into the portal, and you get to take advantage of it in your application. Figure B.1 shows four portlets running in a single web page.

B.2. Portlets, frameworks, and other languages

B.3. Understanding the structure of a portlet