Wednesday, September 28, 2011

Why Portlets in Action?

This post was posted long time back. Bringing it back on top.

I received many queries recently regarding coverage of topics in Portlets in Action book and why its an important book in the context of developing portals and portlets. In this post I'll try to highlight what is covered in Portlets in Action and why. For the complete ToC of the book, please refer to the page dedicated to the book at Manning's web site: http://www.manning.com/sarin/
When I started the book, the objective was to create a book that is useful to the following sections of readers:
- Java web developers/architects new to portal and portlet development
- experienced portlet or portal developers/architects who want to know about Portlet 2.0 features
- experienced portlet or portal developers/architects who want a reference guide to portlet development
As with all Manning 'in Action' books, Portlets in Action comes with a large number of examples which you can quickly import into Eclipse IDE, build using ANT and Maven, deploy and run portlets on any Portlet 2.0 compliant portlet container. As there are usually minor differences between deploying portlets on different portal servers, the source code is provided for both GateIn and Liferay portal servers. As chapter 15 didn't require developing an example portlet, all other chapters in the book have associated example portlets.
The book follows a tutorial-ish approach in which the requirement for an example portlet is described at the beginning of the chapter, and the rest of the chapter focuses on portlet concepts which are required in implementing the portlet.
It's important to note that the book is not specific to Liferay or GateIn. The examples and concepts explained in the book apply to any portal server which is Portlet 2.0 compliant. There are many MEAP readers who are using WebSphere or uPortal for understanding portlet and portal development as explained in the book.
Now, coming to different parts of the Portlets in Action book:


Part I : Getting started with portlet development - This part consists of 5 chapters which introduces readers to portal and portlet development concepts. You'll learn how to develop simple portlets like Hello World, User Registration and complex portlets like Book Catalog portlet.


Part II: Developing portlets using Spring and Hibernate - This is where you'll find details on how to develop portlets using Spring and Hibernate. If you're developing multi-page portlets or you're looking for a standard framework for developing portlets, then this part provides 2 chapters on Spring and Spring Portlet MVC and 1 chapter on Hibernate. 
You don't need to have any experience working on Spring/Hibernate for getting started with these 3 chapters. 
The Spring chapters introduce readers to basics of Spring, Spring Portlet MVC, Spring's Validation framework, JSR 303 - Bean Validation, Annotation-driven development using Spring, testing using Spring's TestContext framework, and so on. You'll final all the latest and greatest techniques that you'll need to develop portlets using Spring in these 2 chapters (approx. 100+ pages).
The chapters on integrating portlets with database shows how you can use Spring JDBC and Hibernate to interact with a database. In this chapter you'll also see Aspect-oriented development support in Spring and transaction management support in Spring.
So, almost 140+ pages in the book is dedicated to developing portlets using Spring and Hibernate.


Part III: Advanced portlet development - This part consists of multiple topics which are some of the most exciting topics in portlet development - inter-portlet communication, personalization, AJAX support in portlets, WSRP, portlet filters and portlet bridges. You'll find lot of examples in each of these chapters (except chapter 15 which didn't require developing an example portlet) to explain each of the topics.
The AJAX chapter is one chapter which goes in detail on developing portlets using AJAX or Comet (Reverse-AJAX). It's a norm these days to develop portlets which are highly interactive in nature. If you're looking for resource on how to create rich portlets using AJAX or Comet, then this chapter shows how you can make use of AJAX support in Dojo, DWR, jQuery to create a hight interactive portlet. If you're new to AJAX, even then this chapter should be sufficient to get you started with AJAX.
The chapter on Portlet Bridges makes use of portletfaces JSF-portlet bridge to show how an example JSF 2.0 web application can be exposed as a portlet. It also shows how to expose an existing Wicket web application as a portlet using WicketPortlet class.

Monday, September 26, 2011

Portlets and their complexity

Time to time I receive questions regarding complexity of the Portlet components. In this post, I'll try to add my 2 cents to discussions regarding complexity related to developing portals, and specifically custom portlet development.

Around 10-12 years back when I started developing applications using JSPs and Servlets, it was difficult because of ad hoc ways we followed....using different design patterns. Then, we moved on to using Struts web framework, and web application development became quite easy. Along the way came many more web frameworks with their own set of unique features.

Portlets are a different beast because of their unique lifecycle. Their lifecycle is complex only as long as you don't understand it. After that it is like a walk in the park. It follow the PRG (Post-Redirect-Get) pattern. If you know PRG, you can quickly correlate it with portlet lifecycle. What Portlets can do is something quite amazing....showing windowed applications in a single page (content aggregation) with well defined mechanisms for communication (inter-portlet communication) and built-in feature for personalizing each such windowed application in the page.

If I compare Portlets to GWT, I find GWT comparatively more complex than Portlets....compile-time code translation, deferred binding, using Gin for dependency injection, MVP architecture that talks about activities and places, and so on. If I look at Flex, it's also similar to GWT in terms of complexity. Singling out Portlets as a complex solution to building portals is not justified. If you're using Spring Portlet MVC (which has the distinction of the only MVC framework designed specifically for building Portlets) you'll find that it results in a very intuitive design of your custom portlets. Chapter 7 and 8 of Portlets in Action demonstrate that you can quickly put your Spring skills in portlet development in no time. Testing of portlets is also simplified if you are using Spring's TestContext framework for unit and integration testing.



Sunday, September 25, 2011

Spring Portlet MVC - Ajax

I have created an example that shows how you can use @ResourceMapping annotation of Spring Portlet MVC to return JSP content as response to an Ajax request. You can find the details of the example in the following post in Author Online Forum of Portlets in Action: http://www.manning-sandbox.com/thread.jspa?threadID=46135&tstart=0

Monday, September 12, 2011

Portlets in Action pBook release

Manning has announced that Portlets in Action book (http://manning.com/sarin) will be released on 16th September. I hope you enjoy reading the book. If you have any queries then please post it in Author Online forum.