6.1 Portlet development

 < Day Day Up > 



6.1 Portlet development

Although portlets can be developed using a simple text editor and the Java Development Toolkit, the tool of choice for portlet developers is WebSphere Studio Application Developer (Application Developer); see reference:

http://www-3.ibm.com/software/awdtools/studioappdev/

In addition the Bowstreet Portlet Factory available from the Portlet Catalog NavCode® 1WP10009Y can be used with Application Developer to provide rapid portlet development using a library of portlet components. Section 6.4.3, "Installing portlets obtained from the Portlet Catalog" on page 215 provides more information about the Portlet Catalog.

Application Developer V4.0.3 for Microsoft Windows is provided as part of the development environment for WebSphere Portal on z/OS. The development environment using Application Developer can be configured to include WebSphere Application Server AEs and WebSphere Portal Server for the debugging of portlets within Application Developer.

The IBM Portal Toolkit provides the capabilities to customize and manage the enterprise portal and create, test, debug and deploy individual portlets and Web content. Templates enable developers to quickly and easily create their own portlets. The Portal Toolkit plugs into Application Developer to provide a comprehensive framework for the development of e-business portal applications.

This installation and setup of Application Developer with WebSphere Application Server AEs, WebSphere Portal Server and Portal Toolkit is described in Chapter 3, "Development environment installation" on page 93.

Portlets overview

Portlets are reusable components that provide access to Web-based content, applications, and other resources. Companies can create their own portlets or select portlets from a catalog of third-party portlets. Portlets are intended to be assembled into a larger portal page, with multiple instances of the same portlet displaying different data for each user.

From a user's perspective, a portlet is a window on a portal site that provides a specific service or information, for example, a calendar or news feed. From an application development perspective, portlets are plug-able modules that are designed to run inside a portlet container of a portal server.

The portlet container provides a runtime environment in which portlets are instantiated, used, and finally destroyed. Portlets rely on the portal infrastructure to access user profile information, participate in window and action events, communicate with other portlets, access remote content, lookup credentials, and to store persistent data. The Portlet API provides standard interfaces for these functions, and is implemented by an extension of the servlet API.

IBM is working with other companies to standardize the Portlet API, making portlets interoperable between portal servers that implement the specification. The Portlet API offered in WebSphere Portal Version 4.1 is the first step toward the Portlet API standardization. For more information about the portlet specification, see:

http://jcp.org/jsr/detail/168.jsp

The Portlet API is described in detail in the InfoCenter at:

http://publib.boulder.ibm.com/pvc/wp/current/ena/en/InfoCenter/index.html

Portlets run inside the portlet container on the portal server, which is able to use services provided by the servlet container of the application server. Therefore, the portal container relies on the J2EE architecture implemented by WebSphere Application Server. As a result, portlets are packaged in WAR files similar to J2EE Web applications and are deployed like servlets. Like other servlets, a portlet is defined to the application server using the servlet deployment descriptor (web.xml). This file defines the Portlet's class file and read-only initialization parameters.

Portlet development

The Portlet Development Guide is available from:

http://www7b.software.ibm.com/wsdd/zones/portal/portlet/portletdevelopmentguide.html

It provides an overview, examples of developing portlets, as well as using JSPs for presentation, and is recommended reading for portlet developers.

Note 

The Portlet Development Guide has been updated for WebSphere Portal V4.2 on Multiplatforms. Although some of the examples are not applicable to WebSphere Portal Enable V4.1 for z/OS it is still recommended reading for portlet developers.

Portlets with WebSphere Portal Enable on z/OS

Many of the portlets available for WebSphere Portal Enable V4.1 for z/OS are described in the document Viewing the WebSphere Portal V4.1 Portlets available at:

http://www7b.software.ibm.com/wsdd/library/techarticles/0301_son/0301_son.html

6.1.1 Using Application Developer to develop a portlet

In "Installing the Portal Toolkit" on page 104 we used WebSphere Studio Application Developer to develop MyFirstPortlet to test the development and debug environment of Application Developer as shown in Figure 6-1.

click to expand
Figure 6-1: MyFirstPortlet in WebSphere Studio, View.JSP

This portlet did not require the developer to add or provide any custom Java code, and used two Java beans to execute the MVC model of the portlet, and several JSPs to display the text output.

The IBM WebSphere Developer Domain Portal Zone and WebSphere Studio Zones are found at:

http://www7b.software.ibm.com/wsdd/

These zones provide many useful articles on developing portlets including the obligatory Hello World example. The portlet Java code for this is shown in Example 6-1:

Example 6-1: Simplest Hello world portlet example

start example
 package com.ibm.portlets.sample; //portlet APIs import org.apache.jetspeed.portlet.*; import org.apache.jetspeed.portlets.*; //Java stuff import java.io.*; public class HelloWorld extends AbstractPortlet {   public void service(PortletRequest request, PortletResponse response)     throws PortletException, IOException {     PrintWriter writer = response.getWriter();     writer.println("<p>Hello World!</p>");   } } 
end example

WebSphere Developer Domain article Developing and Invoking a Servlet from a Portlet using WebSphere Studio is found at:

http://www7b.software.ibm.com/wsdd/techjournal/0302_konduru/konduru.html

This article describes how to develop a portlet using Application Developer and use the portlet to invoke a servlet also developed using Application Developer.



 < Day Day Up > 



Websphere Portal on Z. OS
Websphere Portal on Z/OS
ISBN: 0738499382
EAN: 2147483647
Year: 2003
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net