Thursday, October 28, 2010

JSR 168 Tutorial - part I


What is JSR 168?

•From the portletdevelopment point of view, it is really very simple:

–You write a java class that extends GenericPortlet.

–You override/implement several methods inherited from GenericPortlet.

–You use some supporting classes/interfaces

•Many are analogous to their servletequivalents

•Some (portletsession) actually seem to be trivial wrappers around servletequivalents in Pluto.

Some Terminology

Portlet: Java code that manages a piece of web content and which may invoke services.

PortletContainer: Manages the lifecycle of the portlets (inits, invokes,destroys).

Portal: Displays the portal content provided by the container. The portal is responsible for the actual layout.

Portlet Application: A webappcontaining a group of related portlets, content, supporting jars, etc.

The Big Picture

•As a portletdeveloper, the previous set of classes are all you normally touch.

•The portletcontainer (Pluto) is responsible for running your portlets.

–Init, invoke methods, destroy.

•Portletshave a very limited way of interacting with the container.

–It is a black box->black hole.

–The API is basically one-way.

Some Generic Portlet Methods

Init : Called when the portlet is created. Override if you need to set initial params.

doView : Controls what happens immediately before the portlet is displayed in view mode. Normally you override this.

doHelp, doEdit

Other portlet display modes

processAction : Place for handling any

html form actions before turning over to the display mode method (like doView). You should override this for web forms.

Some Supporting Classes/Interfaces

PortletContext

Similar to servlet context; get context info and the RequestDispatcher from here.

PortletSession

Stores attribute information for a single portlet application across multiple requests.

RenderRequest, RenderResponse

The request and response objects available to the doView() method. Similar to the normal servlet request

ActionRequest,ActionResponse

The request and response objects available to the processAction() method. Similar to the servlet request and response objects.

PortletURL

Use this to create URLs that reference the portal.

PortletRequestDispatcher

Use this to include/forward to a JSP or servlet in the same portlet app.

WindowState

See if you are in minimized, maximized, normal state.


Stumble
Delicious
Technorati
Twitter
Facebook

0 Comments:

Post a Comment