Friday, December 9, 2011

Spring Portlet MVC basics

In this post I've shown one of the figures from Chapter 7 of Portlets in Action book, which depicts how Spring Portlet MVC framework works.


The DispatcherPortlet acts as the front
controller for each portlet and finds the handler mapped (which is HelloWorldController in the above diagram) to the request using HandlerMapping. The
result of executing a handler, ModelAndView, is used to resolve the actual view to be rendered, and
the request is dispatched to ViewRendererServlet for rendering.

Tuesday, November 29, 2011

Portlet request lifecycle phases

In this post I've shown figures from Portlets in Action book that depict action, render and resource request lifecycle phases.

Action and render request lifecycle phases

Figure 2.6 A portlet’s request-processing phases apply to incoming requests based on the request type (action or render). The portlet’s render method is always called to ensure that the updated portlet content is displayed by the web portal.



Resource request lifecycle phase (for handling AJAX use cases)

Figure 12.1 Ajax request handling. JavaScript in the portal page sends an
asynchronous request to a servlet or portlet component, which processes the
request and returns an HTML, XML, text, or JSON response to the browser.
JavaScript in the portal page makes use of the response data to update a part
of the portlet’s content.


Saturday, November 5, 2011

What is a portlet bridge?


[The above figure is from Chapter 14 of Portlets in Action book]
A portlet bridge acts as a bridge between portlet and web application environments. It translates requests from the portlet container into something that the web application can understand, and translates response from the web application that the portlet container can understand.

Thursday, November 3, 2011

Developing JSF and Wicket Portlets

If you want to develop portlets using JSF 2.0, then you can use Portletfaces bridge: http://www.portletfaces.org/projects/portletfaces-bridge


A portlet bridge is a component that sits between the portlet environment and a web
application. It’s responsible for bridging the differences between the portlet environment
and the environment in which the web application is designed to execute.


Chapter 14 of Portlets in Action shows how you can build JSF portlets using Portletfaces bridge or Wicket portlets using WicketPortlet class. It shows how you can first create a web application and then convert it into a portlet by making a few changes to it.

Monday, October 17, 2011

Portal servers covered in Portlets in Action

Portlets in Action uses Liferay 6.0.5 as the reference portal server but it contains additional details for Glassfish (with OpenPortal Portlet Container), Jetspeed and a dedicated appendix for creating a web portal using GateIn Portal. As Liferay has been used as reference, Chapter 1 provides a quick start to Liferay Portal, and as you go through remaining chapters of the book, you'll find more details about Liferay. Chapter 5 is dedicated to Liferay, and it shows how to build a complete web portal in Liferay.

The book assumes that readers have no prior experience working with Liferay, GateIn or Jetspeed servers, Spring, Ajax, Comet, Hibernate, Spring Portlet MVC, and other related technologies. So, the book is for  developers new to Java Portlet technology and for experienced portal architects.

The book attempts to compare features offered by Liferay, Glassfish (with OpenPortal Portlet Container) and Jetspeed, so that readers get a better idea about the portal servers. At the heart of the book is the Spring Portlet MVC Framework, which you can use to simplify portlet development. Real world portlet development projects require using Spring Portlet MVC, Ajax, Comet (Reverse Ajax), WSRP, Hibernate or Spring JDBC, AOP, Inter-portlet communication using different mechanisms, Personalization, JSR 303 for validation, and so on.

Some of the book examples have been tailored for GateIn, and you can find them here: http://code.google.com/p/portletsinaction-gatein/

Liferay examples are located here: http://code.google.com/p/portletsinaction/downloads/list

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.

Monday, August 1, 2011

Status of Portlets in Action book

Portlets in Action (http://manning.com/sarin/) book is now complete and is scheduled for publishing in September. I don't expect the book to be delayed any further because the final review of all chapters is complete and Chapters 1-13 have already been typesetted.

Monday, May 16, 2011

Separate examples for handler mappings

I've updated Chapter 7 example (ch7_HandlerMappings) to include separate Book Catalog portlets for ParameterHandlerMapping and PortletModeParameterHandlerMapping. Earlier, the examples were combined together to show handler mapping chain behavior.

The updated code is available in SVN (http://code.google.com/p/portletsinaction/source/checkout) and it'll be available for direct download (as a ZIP file) when the last MEAP version of Portlets in Action is released.

Articles from Portlets in Action

Caching generated contenthttp://tinyurl.com/6f3vd2x

PortletSession-based Inter-Portlet Communicationhttp://tinyurl.com/6hvtjxw

Portlets in Action book status

I started writing Portlets in Action sometime in Aug or Sep, 2009. When I started, I felt it'll take forever to complete the book as it kept growing with every feedback from reviewers and from the readers in Author Online forum. Y'day I addressed the review comments that I received from the copy-editor, and finally got the feeling that now Portlets in Action has reached the final stage of publishing. I guess the next step is typesetting, which'll not require much effort from my side.
It's strange that my other book 'Spring Roo Cookbook' is also nearing completion now. I'm not sure which one gets published first, but it seems like its going to be a close contest. 

Wednesday, April 13, 2011

New blog for Spring roo

As I want to keep Portlets in Action related blog entries separate from Spring roo cookbook, I'll be writing about Spring roo in my other blog : http://spring-roo.blogspot.com/. For any updates on Spring roo cookbook please refer to the new blog.

Friday, April 8, 2011

List of recipes in Spring roo cookbook

You can find the list of recipes covered in Spring roo cookbook here: http://groups.google.com/group/spring-roo-cookbook/browse_thread/thread/590538302274b0b1

If you have any questions on the book, then please post it in the Google group for the book: http://groups.google.com/group/spring-roo-cookbook/

NOTE: The recipe list might change before the book goes into production.

Monday, February 28, 2011

Spring Roo Cookbook by Packt Publishing

I've been working on the Spring Roo Cookbook for last few months, and today it was announced by Packt Publishing under RAW. Currently first 2 chapters of the book are available under RAW.

You can find the details of the book here: https://www.packtpub.com/spring-roo-1-1-cookbook/book

If you have any questions on the book, then please post your comments in the Google group that I have specifically created for discussing the book: http://groups.google.com/group/spring-roo-cookbook


Sunday, February 13, 2011

a new IPC example using JS functions

I have posted a new IPC example in which JS function of the communicating portlets is invoked. You'll find more details about it in the following post: http://www.manning-sandbox.com/thread.jspa?threadID=41862&tstart=0

Thursday, January 6, 2011

JSF 2.0 portlet bridge example updated

The JSF 2.0 Portlet bridge example in chapter 14 of Portlets in Action book is now updated to use 2.0.0-Beta3 release of portletfaces bridge. The updated example can be download from google code project for Portlets in Action book: http://code.google.com/p/portletsinaction/