. 47
( 87 .)


poll. The portlet will present a question and a series of answer choices from
which the user can make a selection and then register a vote.
Figure 15-1 shows a screen capture of a portal page that contains the Poll
portlet. If the user who is logged in to the portal has not yet voted, the
portlet displays the question and answer choices. When the user has voted,
the view will change to display a graphical representation of the current
voting totals for the answer options, as shown in Figure 15-2.

WY009-15 WY009-BenNatan-v1.cls May 11, 2004 14:50

276 Chapter 15

Figure 15-1 Portal page with poll portlet.

The portlet will also provide both an edit mode and a con¬gure mode.
In con¬gure mode the administrator will (1) de¬ne the persistence store
option for the portlet, (2) de¬ne the name of a new poll to be created or select
an existing poll to be associated with this portlet instance, and (3) modify
the poll question and answer selection choices. A portlet instance can be
con¬gured to display a poll that is in progress (votes have been recorded
against the poll with that name), but in that case the poll question and
answer choices cannot be modi¬ed.
Figures 15-3 to 15-5 show the con¬guration pages of the portlet. In the
¬rst page the persistence store is de¬ned. The portlet will need to store the
portlet question and answer choices as well as the number of votes cast. This
poll information can be held in memory or in a database. If the data is held
in memory then it is lost when the portal is restarted. This option is useful
for demonstration and portlet testing purposes. The poll data is not actually
persistent. If a database is used to store the poll information then the portlet
WY009-15 WY009-BenNatan-v1.cls May 11, 2004 14:50

WebSphere Portlet Development Environment 277

Figure 15-2 The Poll portlet.

Figure 15-3 Portlet con¬guration page specifying persistence store.
WY009-15 WY009-BenNatan-v1.cls May 11, 2004 14:50

278 Chapter 15

Figure 15-4 Portlet con¬guration page identifying poll by name.

must be con¬gured to specify the database information. The database data
source name must be speci¬ed here. The Verify button will test to ensure
that the datasource name is de¬ned correctly in the application server and
that the tables have been correctly created to support the portlet.
In the next con¬guration page the portal administrator identi¬es the poll
by a unique name (see Figure 15-4). A new poll can be created by specifying
a unique name here or an existing poll can be chosen from the drop-down
In the last con¬guration page the portal administrator de¬nes the poll
question and the answer choices (see Figure 15-5). If the poll selected is an
exiting poll that is in progress, then the question and answer choices cannot
be modi¬ed.
These portlet con¬guration changes are applicable to the concrete portlet
instance. You can copy the portlet multiple times and put the copied ver-
sions on portal pages each de¬ning a different poll (also with potentially
different persistent store options). These con¬guration parameters will be
held in PortletSettings when implemented using the IBM Portlet API.
When implemented using the JSR 168 API, these values will be managed
through the PortletPreferences object.
Finally, there is an edit mode for the portlet. In edit mode the portlet user
(as opposed to the portal administrator who con¬gured the portlet) can
customize the portlet (see Figure 15-6). For this simple portlet the level of
user-speci¬c customization is minimal. We allow the user to select the color
that will be used on the bar graph, which displays the current voting totals
for the poll. As with the con¬guration settings, the customization values
can be speci¬ed uniquely for each poll portlet that the user has deployed
on portal pages. Unlike the con¬guration portlet settings these options are
WY009-15 WY009-BenNatan-v1.cls May 11, 2004 14:50

WebSphere Portlet Development Environment 279

Figure 15-5 Portlet con¬guration page de¬ning poll question and answer choices.

speci¬c to a user. Using the IBM Portlet API these parameters are held in
PortletData. When the portlet is implemented using the JSR 168 API
these parameters are held in PortletPreferences.
In edit mode the user can select a speci¬c color or select to have the color
be the same as the color of the portlet toolbar as de¬ned by the current
portlet skin.

Figure 15-6 Edit mode: color selection.
WY009-15 WY009-BenNatan-v1.cls May 11, 2004 14:50

280 Chapter 15

WebSphere Studio
WebSphere Studio is the integrated development environment (IDE) plat-
form of choice for building portlets for WebSphere Portal. It provides edi-
tors, builders, and wizards for Java application development. WebSphere
Studio is built on Eclipse technology, an open platform for tool integration.
Eclipse provides common function on its open platform for tool vendors
to provide advanced development environment functionality such as team
programming, the user workbench and user interface, and interactive de-
bugging. Eclipse is both an integrated development environment and a tool
integration platform. WebSphere Studio provides functional enhancements
to the Eclipse IDE.
WebSphere Studio version 5 supports JDK 1.3 and provides support for
adding additional JRE de¬nitions and switching between Java levels. The
Java development environment provides automatic incremental compi-
lation, local and remote interactive debugging, customizable and con¬g-
urable workbench perspectives, views, and editors. The workbench also
provides an extensive search capability and a scrapbook where Java code
snippets can be evaluated easily and execution results inspected.
WebSphere Studio provides a rich set of tools to support Web application
development. WebSphere Studio version 5 supports development of Web
applications that meet the J2EE 1.3 speci¬cation, which includes the Sun
Microsystems Java Servlet 2.3 speci¬cation and the Sun Microsystems JSP
1.2 speci¬cation. Web application support includes Web project creation.
This creates an application project using the J2EE hierarchy and includes
the creation of the Web application deployment descriptor ¬le (web.xml).
The development environment supports Java Server Pages (JSP) creation,
validation, editing, and debugging. JSP tooling also includes support for
JavaScript editing and validation and custom JSP 1.2 tag development sup-
port. Web Archive (WAR) ¬les can be imported, exported, and validated.
There are a variety of additional tools for editing images and Cascading
Style Sheets (CSS), a Web site designer, wizards for servlet creation, and
integration with the WebSphere test environment.

Portal Toolkit
The IBM Portal Toolkit extends WebSphere Studio further by providing a
complete set of tools for developing portlet applications. The Portal Toolkit
provides support to create, debug, and deploy individual portlets and port-
let applications. Wizards and templates assist in developing portlet project
and portlets, while powerful interactive debugging capability dramatically
reduces development and test time for portlet developers.
WY009-15 WY009-BenNatan-v1.cls May 11, 2004 14:50

WebSphere Portlet Development Environment 281

The mechanism for extending the Eclipse-based Studio environment is
through plug-ins. The development environment is designed for extensi-
bility. The Portal Toolkit is a plug-in for either WebSphere Studio Applica-
tion Developer (WSAD) or WebSphere Studio Site Developer (WSSD). As
mentioned before, WebSphere Portal ships with WSSD. We refer to either
product generically as Studio.

N O T E The latest information, including documentation and downloads, about
the Portal Toolkit is available on the WebSphere Portal Toolkit Web site at

The toolkit provides the following portlet development tools and IDE

Portlet Project
A new project type is de¬ned for portlet applications and a wizard tool is
available to create portlet projects. A portlet project is similar to a J2EE Web
application project and includes a Web deployment descriptor that de¬nes
the Web application. In addition, a portlet project contains a portlet deploy-
ment descriptor ¬le (portlet.xml) that de¬nes the portlet application
and the portlets within that application.
The portlet application wizard assists in the creation of the project direc-
tory structure, the Web deployment and the portlet deployment descriptors,
and a set of sample Java source ¬les that make up the portlet application.
The amount of generated code is dependent on the type of portlet applica-
tion that was selected in the wizard: an empty portlet application or a basic
portlet application.

Portlet Perspective
A new perspective is provided for portlet development. A perspective in
Studio de¬nes a set of views and the layout of those views along with a
set of editors. Studio de¬nes multiple perspectives each aimed at a speci¬c
task or a speci¬c type of resource. For example, the Web perspective shows
workbench views that are appropriate to Web application resources. The
debug perspective shows views that apply to the interactive debug of Java
The portlet perspective is similar to the Web perspective provided by
Studio, showing views and editors for Web application resources. In addi-
tion, this perspective provides an editor speci¬c for the portlet deployment
descriptor ¬le (portlet.xml). The portlet.xml editor also assists in
WY009-15 WY009-BenNatan-v1.cls May 11, 2004 14:50

282 Chapter 15

keeping the portlet and Web deployment descriptors in sync. As discussed
in a previous chapter there are links between the Web deployment descrip-
tor and the portlet deployment descriptor. The servlet ID de¬ned in the
web.xml ¬le must link to the portlet href attribute in the portlet applica-
tion de¬nition in the portlet.xml ¬le. The portlet.xml editor manages
this and other associative descriptor attributes. The editor also provides a
validator to check the deployment descriptor de¬nitions.

Portal Server Con¬guration
The Portal Server Con¬guration de¬nes a WebSphere Studio server con¬g-
uration that allows you to publish your portlet application to WebSphere
Portal. Published portlets are deployed on a debug page of WebSphere
Portal. Interactive debugging is supported.
A portlet application can be published and debugged in a local portal test
environment or a remote (attached) portal server. Local debugging requires
that you install the WebSphere Portal for a test environment. You can use the
Portal Toolkit installer to set up the Portal test environment. Once installed
and started you can interactively make changes to your portlet in Studio
and immediately test the change on the local portal without an additional
package, publish, or deploy step.
You can use remote debugging for portlets running on a portal server
outside the Studio environment. To enable remote debugging you need to
con¬gure the JVM for the WebSphere Portal Application Server instance.
Debug mode needs to be enabled, with the debug arguments set to

-Djava.compiler=NONE -Xdebug -Xnoagent -

We will look at portlet developing using Studio in more detail in Chapter
16 and explore interactive debugging using Studio in Chapter 17.

Portlet Preview
Portlet preview allows you to preview the portlet under development as de-


. 47
( 87 .)