Oracle9iAS Portal Developer Kit
Understanding the HelloWorld - Java Portlet Sample

The PDK-Java (JPDK) provides developers with 6 Java portlet samples to view and build upon. This article describes the HelloWorld Portlet sample in detail. This article is separated into two sections. The first section, Function, describes the overall behavior of the HelloWorld Portlet. The second section, Show Modes, describes the detailed behavior and function within each mode of the sample.

### FUNCTION

PDK-Java provides a sample called HelloWorld Portlet. The HelloWorld Portlet is servlet based and implements PortletRenderer. PortletRenderer is the Provider Interface that defines how to render a portlet with Oracle9iAS Portal. The HelloWorld Portlet displays 6 of 7 show modes including show, edit, editdefaults, help, about, and full screen. The sample displays a welcome greeting and session storage information. The logged-in user has the ability to personalize the portlet greeting and title, but only an administrator can customize the default settings for the portlet greeting and title. The user can access more information about the portlet as well as helpful information by clicking on the Help and About links. If the user wants to reset the session information, the user can click on the Portlet title.

The HelloWorld Portlet is created using the following class files located within the /src/oracle/portal/sample/helloworld and /src/oracle/portal/sample/helloworld/resource directories. Please review the source code for more information on creating the Web Service Portlet.

- HelloWorldBundle.class - a ResourceBundle to localize portlet information and message strings.

- HelloWorldRenderer.class - an implementation of PortletRenderer that handles rendering the portlet show modes.

- HelloWorldCustomization.class - an subclass of BaseCustomization. It allows users to customize the portlet greeting. Since it subclasses BaseCustomization, users can also customize the portlet title.

### SHOW MODES

Each show mode has a function that enhances the HelloWorld Portlet. This section describes each show mode in detail.

Show Mode

In the show mode (MODE_SHOW), the HelloWorld Portlet displays 3 types of information. The first message is the greeting. The greeting, Welcome <USER> to Oracle Portal Introductory Example!, concatenates a welcome message around the name of the logged-in user. This is the default greeting for the HelloWorld Portlet and can be personalized by the logged-in user. The second message is session storage information. The session storage, This portlet has rendered 2 times in this session, counts the number of times the portlet has rendered in the current session. The user can logout and login to the page to clear the current session. The final message, Last updated on <date>, displays the current date and time.

Before rendering the portlet, the show mode retrieves the default or personalized greeting from HelloWorldBundle. It also checks to see if the session has cleared. If session has cleared, it starts the render count from 1, otherwise it adds a value of 1 to the render count and displays that value.

Edit Mode

In the Edit Mode (MODE_EDIT), the HelloWorld Portlet allows users to personalize the portlet title and portlet greeting. The portlet title is simply the name the user would like to see on the portlet header. The portlet greeting currently takes {0} as an argument representing the logged-in user. The user can change the greeting to display any information in a text format. The customization for both the portlet title and greeting are stored in serialized file in the file system on the Web Provider server. When a user customizes the HelloWorld portlet, they only change their personal view of the portlet. A user accesses Edit Mode by clicking on the Customize link at the top-right of the portlet header. Only an administrator can change the default settings for the portlet using EditDefaults Mode (MODE_EDIT_DEFAULTS).

EditDefaults Mode

In the EditDefaults Mode (MODE_EDIT_DEFAULTS), the HelloWorld Portlet allows an administrator to set the default title and greeting for the portlet. The functionality of this mode is the same as Edit Mode, but when stored in a serialized file, it is labeled for the default setting. An administrator accesses EditDefault Modes by clicking on Customize Page at the top-right of the Portal page, then clicking on EditDefaults at the top-right of the portlet header.

Help Mode

In Help Mode (MODE_HELP), the HelloWorld Portlet provides information on how to use the portlet. The help greeting and title are retrieved from HelloWorldBundle. A user accesses Help Mode by clicking on Help at the top-right of the portlet header.

About Mode

In About Mode (MODE_ABOUT), the HelloWorld Portlet provides information about the portlet and its current release. The about greeting and title are retrieved from HelloWorldBundle. A user accesses About Mode by clicking on About at the top-right of the portlet header.

Full Screen Mode

In Full Screen Mode (MODE_SHOW_DETAILS), the HelloWorld Portlet displays the portlet in a full screen. Because of space limitation in the show mode, full screen mode offers a Clear count button to clear the current session information without logging out of the Portal page. The full screen mode also determines in your current language is English or German and displays the greeting accordingly. It retrieves both the session and language greeting from HelloWorldBundle. A user access Full Screen Mode by clicking on the portlet title at the top-left of the portlet header.

Revision History:

- November 21, 2000.