Feature
Inter-Portlet Communications
Using IBM Rational Application Developer V6.0
Aug. 17, 2005 01:00 PM
This article demonstrates the steps performed to implement JSR 168 compliant cooperative portlets using IBM Rational Application Developer V6.0 and WebSphere Portal Server V5.1. The article illustrates passing multiple values from source portlet to target portlet without defining complex data type inside WSDL file.
The term cooperative portlets refers to the capability of portlets on a page to interact with each other by sharing information. One or more cooperative portlets on a portal page can automatically react to changes from a source portlet triggered by an action or event in the source portlet. Portlets that are targets of the event can react so that users are not required to make repetitive changes or actions in other portlets on the page. Cooperation between source and target portlets is facilitated by a WebSphere Portal runtime entity called the property broker. Portlets on a page can cooperate in this way even if they were developed independently, without the programmer's awareness of the existence of the other cooperative portlets.
JSR 168 is a specification from the Java Community Process for portlet development. IBM WebSphere Portal V5.1 provides support for the JSR 168 API. With an IBM extension, WebSphere Portal V5.1 supports cooperative portlets for JSR 168 portlets, in which one JSR 168 portlet can communicate with another JSR 168 portlet.
To develop and deploy the sample application, we used the following IBM products:
- Rational Application Developer for Rational Software Development Platform V6.0
- WebSphere Portal V5.1.x
Introducing the DemoPortlets scenario
In the DemoPortlets scenario we are going to create two JSR 168 portlets. The DemoPortlet1 will pass the multiple values to the DemoPortlet2 without defining complex data type inside WSDL file.
DEMOPORTLET1:
Gets the input from the user in three fields and then passed these input values to the target portlet. This portlet is our source portlet. (See Figure 1.)
DEMOPORTLET2:
Act as a target portlet and retrieve those three entered values from DemoPortlet1 and display them on the page. (See Figure 2.)
Create Portlet Project (JsR 168)
Start the IBM Rational Application Developer (IRAD).
- With the IRAD workbench started, switch to the Web perspective by clicking Window > Open Perspective >Web.
- Click New > Other
- Select Portlet Project (JSR 168) from the list. This launches the New Portlet Project (JSR 168) wizard (See Figures 3 and 4.)
- Enter DemoPortlets as the Name.
- Clear the Create a portlet checkbox. You will create your portlets separately in order to have better control over portlet naming conventions.
- Click the Show Advanced button.
- Select WebSphere Portal v5.1 Unit Test Environment in the Target Server list.
- Accept defaults for the other fields.
- Click Finish
Create DemoPortlet1 (JSR 168)
- Select the DemoPortlets project in the Project Navigator view.
- Right-click to bring up the context menu, and click New > Portlet. This launches the New Portlet wizard
- Enter DemoPortlet1 as the Default Name prefix, click Next (See Figure 5.)
- Accept default values and click Finish.
Create Portlet2 (JSR 168)
As a same way create DemoPortlet2 portlet.
Enabling the DemoPortlet1 as a source
JSR 168 portlets can cooperate with each other by exchanging properties via the property broker. A WSDL file describes publish (or send) to the property broker.
DESCRIBING THE SOURCE WITH WSDL
To enable our DemoPortlet1 portlet as a property source, simply right-click the portlet in the Project Explorer view to display the Enable Source (See Figure 6.)
Once the Enable Cooperative Source wizard launches enter the illustrated values: (See Figure 7.)
- A name for the Data type
- The Namespace for the new data type
- What you want your parameter Bound to
About Asim SaddalAsim Saddal works in the Middleware (WebSphere Application Server, WebSphere Datapower, WebSphere Process Server, WebSphere VE) practice of IBM Software Services for WebSphere.