Wednesday, March 21, 2007

The portlets

This is the article about portlets. It is the first steps to portlets and portal. I am talking about portlets, portals, aggregating portlets to portals, portlet API (JSR168), main portlet’s sides and showing simple portlet code. Prerequisites include understanding of of XML, HTML, Servlets and JavaServer Pages.

How does it work?

Portals are respected by a number of characteristics. The two most often observed by users are:
  • Aggregation
  • Personalization.
These characteristics have a major impact on the programming model, and how it differs from a non-portal web site.

Aggregation refers to taking content from multiple, independent, delivery channels, and providing a unified user experience. A Portal page will often contain multiple
portlets, each rendering content from a separate source. Aggregation is outside of the scope of JSR-168. Many Portal engines manage pages and aggregation differently.

Personalization refers to allowing each user to customize their portal experience. Different portal engines will provide for differing levels of personalization. JSR-168 includes a notion of Portlet Preferences, which a developer can use to allow a user to customize how the portlet
will perform for that specific user.

Portlet is a new type of Web Component, cousin to the Servlet, provides the interface to content.

What Is JSR-168?
The numeric designation for the JCP’s first local Portlet Specification.
Remote portlet technology is defined by the WSRP specification.
Extends Servlet Specification 2.3 with new Portlet concepts.
Defines the standard contract between the Portlet container and Portlet components.
JSR-168 does not define Portal behaviors, such as how pages are laid out, how aggregation works, how administration is performed, etc.

Why JSR-168?
Prior to JSR-168, we had many different Portlet APIs. The lack of standards fragmented the solution space, creating issues for customers and ISVs.

Portlets and servlets
Portlet-based Applications vs Servlet-based Applications Installing a Portlet Application provides capability, not content. Portlets from multiple applications can be
aggregated on the same page. More administration with Portlets and Portals than with traditional web applications.

Portlets Differ from Servlets
  • Two phase request processing
  • Persistent render parameters
  • Portlet render as markup fragments
  • Special URLs to access a Portlet
  • Portlet Modes
  • Portlet Window States
  • Portlet Preferences

Some of the Portal Servers That Support.. JSR-168
Open Source:

MVC and Portlets
Portlets in MVC terms:
  • Portlet class – Controller
  • Portlet’s JSP – View
Model/View/Controller Pattern
  • Model
Abstract interface
No user interaction
No presentation
  • View
Acquires Model data and renders it
Can be replaced, independent of the Model
  • Controller
Receives input events
Provides the means to effect change on the Model
Orchestrates interaction between Model and View
MVC and Portlets
The Portlet's primary role is as the Controller. Receives events from the container
  • Process actions
  • Render content

Portlets typically dispatch to the View (usually a JSP page).
As the Controller, Portlets orchestrate interaction with the Model and moving content to the View. The Model can be anything: POJO, EJB, Web Service, etc. A Portal is intended to provide an aggregated UI to models, not to necessarily contain those models.


1 comment:

Alexey Zavizionov said...

“preference attributes are user specific”
“the portlet container must instantiate and use only one portlet object per portlet definition.”