Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java

Introducing the Portlet Specification, Part 1

Get your feet wet with the specification's underlying terms and concepts

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 2 of 7

Figure 1. Portal architecture. Click on thumbnail to view full-size image.

Page

Figure 2 depicts the basic portal page components. The portal page itself represents a complete markup document and aggregates several portlet windows. In addition to the portlets, the page may also consist of navigation areas and banners. A portlet window consists of a title bar with the portlet's title, decorations, and the content produced by the portlet. The decorations can include buttons to change the portlet's window state and mode (we explain these concepts later).

Figure 2. Portal page. Click on thumbnail to view full-size image.

Portlet

As mentioned above, a portlet is a Java-based Web component that processes requests and generates dynamic content. The content generated by a portlet is called a fragment, a piece of markup (e.g., HTML, XHTML, or WML (Wireless Markup Language)) adhering to certain rules. A fragment can be aggregated with other fragments to form a complete document, as shown in Figure 3. A portlet's content normally aggregates with the content of other portlets to form the portal page. A portlet container manages a portlet's life cycle.

Figure 3. Different portlet markups: on the left side, HTML markup in a desktop browser; on the right side, WML markup on a mobile phone. Click on thumbnail to view full-size image.

Web clients interact with portlets via a request/response paradigm implemented by the portal. Usually, users interact with content produced by portlets by, for example, following links or submitting forms, resulting in portlet actions being received by the portal, which then forward to the portlets targeted by the user's interactions.

The content generated by a portlet may vary from one user to another depending on the portlet's user configuration.

Portlet container

A portlet container runs portlets and provides them with the required runtime environment. A portlet container contains portlets and manages their life cycles. It also provides persistent storage mechanisms for the portlet preferences. A portlet container receives requests from the portal to execute requests on the portlets hosted by it. A portlet container is not responsible for aggregating the content produced by the portlets; the portal itself handles aggregation.

A portal and a portlet container can be built together as a single component of an application suite or as two separate components of a portal application.

Concepts

This section explains the basic programming concepts in JSR 168, such as a portlet's life cycle, interface, and modes and window states, as well as session access, persistent storage access, and how to include servlets and JSP pages.

Portlet life cycle

The basic portlet life cycle of a JSR 168 portlet is:

  • Init: initialize the portlet and put the portlet into service
  • Handle requests: process different kinds of action- and render-requests
  • Destroy: put portlet out of service


The portlet container manages the portlet life cycle and calls the corresponding methods on the portlet interface.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (8)
Login
Forgot your account info?

Excellent for beginnersBy Anonymous on December 15, 2009, 10:55 pmIts awesome...

Reply | Read entire comment

Nice oneBy Anonymous on November 11, 2009, 1:59 amThank you so much .it's veryuseful

Reply | Read entire comment

Nice articleBy Anonymous on September 18, 2009, 8:57 amIt is good introduction to portlets. Appreciate the efforts !

Reply | Read entire comment

A good tutorial finally !By Anonymous on June 26, 2009, 1:05 amA good tutorial finally !

Reply | Read entire comment

Great articleBy Anonymous on March 25, 2009, 9:32 pmThanks for this excellent arcticle.

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources