Datasheet

The portlet session
The window state
The portlet preferences object
The portal context
To change the portlet mode or window state, you call the appropriate method on the
ActionResponse
object. The change becomes evident when the render method is called subsequent to the end of process-
ing in the
processAction method. You can also pass render parameters using the ActionResponse
object.
RenderRequest
RenderRequests generate a fragment from the portlet’s current state. The RenderRequest object pro-
vides access to the following:
The render request parameters
The portlet mode
The portlet session
The window state
The portlet preferences object
There is also an accompanying
RenderResponse method, which provides the vehicle needed to render
content. You can call
getOutputStream or getWriter as you do in a servlet, or you can dispatch the
content generation to a servlet or JSP. There is more detail on this technique later in the chapter, in the
section “Calling JSPs and Servlets.”
GenericPortlet
The GenericPortlet class is an abstract implementation of the Portlet interface. This is the most
common way most users will write portlets by extending this class. The
GenericPortlet class
extends the
render method by setting the portlet title, and then calling its own doDispatch method,
which in turn, determines the mode of the Portlet, and calls its appropriate method:
doEdit for EDIT,
doView for VIEW, and so on. There is more discussion on portlet modes later. The following code
describes a class that extends
GenericPortlet:
package org.opensourceportals.samples;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
The request and response objects are not thread-safe. This means that a developer
should avoid sharing references to them with other threads of execution. Most
developers will not run into this problem, but remember this tidbit next time you
decide to try something unconventional.
11
The Java Portlet API (JSR 168)
04 469513 Ch01.qxd 1/16/04 11:04 AM Page 11