...

IBM Rational Application Developer V7 advanced

by user

on
Category: Documents
46

views

Report

Comments

Transcript

IBM Rational Application Developer V7 advanced
IBM Rational Application Developer V7 advanced
portlet development capabilities: Wiring and WSRP
Part of a series on portal and portlet development
By Jaspreet Singh
Software Engineer
IBM Corporation
Level: Advanced
August 2007
Advanced portlet development with Rational Application Developer V7, Page 2 of 24
Contents
Abstract ........................................................................................................................... 3
Wiring .............................................................................................................................. 3
Wiring across portal pages: Cross-page wiring ........................................................... 3
WSRP standard ............................................................................................................ 14
Adding WSRP support using Portal Designer............................................................ 14
Other articles in this series ............................................................................................ 23
Resources ..................................................................................................................... 24
About the author............................................................................................................ 24
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 3 of 24
Abstract
This article describes the capabilities that IBM® Rational® Application Developer
Version 7 tooling offers on topics that go beyond the basics of portlet application
development and are more likely in a real-life use case. It covers topics such crosspage wiring, which is enablement of cooperative portlets that exist on separate portal
pages, and the WSRP standard, which allows the integration of remote content and
Web applications into an end-user portal. The article also emphasizes the key theme of
Rational Application Developer V7, which is to rapidly develop and deploy applications,
thereby increasing productivity and reducing the learning curve.
Wiring
A typical portal contains more than one portlet. Some of these portlets are independent,
but some may need to communicate with each other. A typical case is where one portlet
displays broad overall information and another set of portlets communicate with this
portlet to display information at a finer, more granular level. The concept of cooperative
portlets takes care of this portlet intercommunication.
In a cooperative portlet environment, there is a source portlet that declares output
properties and a target portlet that declares input properties. However, such a
declaration is incomplete without specifying which portlet acts as consumer and which
as producer. This is where wiring comes in. It takes the enabling of portlets as
cooperatives to a logical conclusion by tying together a source and a target portlet.
A stock exchange is good analogy. There is a set of sellers akin to source portlets. Then
there is set of buyers as the target portlets. The stock exchange brings them together. It
facilitates a transaction where one seller is “tied,” put in touch with, or “wired” to a buyer.
This is a contrived example, of course, but you get the point.
Wiring across portal pages: Cross-page wiring
As previously mentioned, a typical portal application consists of many portal pages.
Each portal page can contain a number of portlets. When a wire is created between a
portlet on one portal page and another portlet on a different portal page, it is called
cross-page wiring. Let us see how Rational Application Developer V7 can be used to
create wires between cooperative portlets.
Note:
Cross-page wiring is relatively a new feature in IBM® WebSphere® Portal. It is
supported in WebSphere Portal 5.1.0.4 and 6.0 by default. Before 5.1.0.3, you will need
to apply PK18538 to the portal server.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 4 of 24
Adding a wire from the Portal Designer in Rational Application Developer
Let us see a wire creation between a source and a target portlet using wiring tool in the
Portal Designer component of Rational Application Developer V7. You can create the
wire without worrying about whether it is an In-page wire or Cross-page wire.
Note:
A Java™ Specification Request (JSR) 168-compliant portlet cannot be wired
to an IBM portlet, nor vice versa.
1. Import or create a portal project in Rational Application Developer V7. A new
portal project can be created by invoking the New Project wizard from File >
New > Project and choosing Portal Project as Figure 1 shows.
Figure 1. Creating a new portlet project
2. Click Next to open the New Portal Project wizard.
3. Type a project name for the portal project, and then click Finish to accept the
defaults and create a portal project.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 5 of 24
Figure 2. New Portal Project wizard
4. Import or create a portlet project with cooperative portlets.
5. Open the Portal Configuration node in the J2EE view (Java™ 2 Platform,
Enterprise Edition) to open the Portal Designer. If you have imported a portal
project in a new workspace, you will need to enable the portal development
capabilities. Also notice the associated Palette view.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 6 of 24
Figure 3. Portal Designer and palette
6. Click and drag Page from the palette to create another page for the portal. Drop
it on Label1 (see Figure 4) to ensure that the new page is at the same level as
Page1. Name the new page Page2.
Figure 4. Creating another page
2. Drop
here
1. Click
and drag
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 7 of 24
7. Lay out the source portlet on Page1 and the target portlet on Page2 (Figure 5).
This can be done by either dragging the portlet onto the page from the palette
(Figure 6) or dragging the portlet from the Project Explorer (Figure 7).
Figure 5. Laying out pages
Figure 6. Dragging the portlet onto the page for layout (Option 1)
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 8 of 24
Figure 7. Dragging the element onto the page from Project Explorer (Option 2)
The source and target portlet look like Figure 8 on the two portal pages.
Figure 8. Example of page layout after moving elements (1 of 2)
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 9 of 24
Figure 9. Example of page layout after moving elements (2 of 2)
8. Select Page1 (which contains the source portlet) in Page Designer.
9. Select the Wires tab in the Properties view. This shows the wires configured on
this page (Figure 10).
Figure 10. List of wires configured on a page
10. Click Add to open the New Wire dialog.
11. Under Source, select the source portlet in the Portlet select box (Figure 11).
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 10 of 24
Figure 11. Selecting the source portlet
12. Select an output property from a Property list box (Figure 12).
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 11 of 24
Figure 12. Selecting an output property
13. Click Browse next to Target > Page if you change the current Target Page. A
Target Page dialog opens (Figure 13).
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 12 of 24
Figure 13. Target Page dialog
14. Select Page2 from the tree list.
15. Click OK.
16. The target page that you selected is displayed on the New Wire page in the
Target page text box.
17. Select a target portlet from the Target Portlet list box.
18. Select an action from the Action list box (Figure 14).
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 13 of 24
Figure 14. New Wire options
19. Click OK to finish adding the wire. The wire that you added is listed in the Wires
table (Figure 15).
Figure 15. Wires table
20. Deploy the portal project on the server.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 14 of 24
WSRP standard
Web Services for Remote Portlets (WSRP) is an OASIS standard to aggregate remote
portlets into a local portal. It is a specification that uses SOAP-based Web services that
retrieve the available remote portlets, markup, and metadata. WSRP basically enables
portal pages to display remotely running portlets (running in a remote portlet container)
in the same way as a locally running portlet (running in a local portlet container).
Because the portlets can be used remotely, the portlet vendor does not need to
distribute the portlets to the clients. This entire interaction occurs through the exchange
of SOAP messages.
We will see how Portal Designer in Rational Application Developer V7 supports the
WSRP standard for IBM WebSphere Portal.
Adding WSRP support using Portal Designer
Typically, a remote portlet is inserted into the local portal page. The portal providing the
remote portlet is called the producer, and the local portal consuming the remote portlet
is called the consumer. The remote portlet is provided as a Web service.
Extending WSRP support involves two tasks, which the Portlet Designer handles:
•
•
WSRP producer creation
Remote portlet consumption
Next, you’ll see how Rational Application Developer V7 takes care of the complete
scenario, from producing to using remote portlets.
Create a WSRP producer to enable a portlet as remote
First, you need to enable a portlet as a remote portlet. The Portal Server tooling in
Rational Application Developer V7 helps you do this.
1. Right-click on the portlet project that contains the portlet that you want to make
remote, and select the Deploy Portlet option. The Deploy Portlet wizard opens.
2. On the Select Server page, the portlet project is selected by default, but you also
need to select the portal server where the portlets are to be deployed.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 15 of 24
Figure 16. Select Server view
3. Click Next.
4. The Portlets page of the wizard opens.
Note:
This is the important page as far as enablement of portlets as remote is concerned.
The Portlets page lists all of the portlets available in the portlet project being
deployed. The column called Provided indicates if the particular portlet will be
available remotely or not after being deployed. The default value is False, and you
can use the drop-down menu too change it to True to enable the portlet as remote.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 16 of 24
Figure 17. Portlets page of the Deploy Portlet wizard
5. The remote availability of the portlets can be verified on the portal server console
too. Portlet Management > Portlets brings up the portlet Search page. The
search result has a Provided field which conveys this information. A tick mark
under Provided means the corresponding portlet is available remotely.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 17 of 24
Figure 18. Verifying that the portlet is available remotely
6. This remote portlet will now be available as a Web service through this URL:
http://<hostname>:10038/wps/wsdl/wsrp_service.wsdl
Make the remote portlet ready to use
In the previous steps, we deployed portlets on a portal server and enabled them as
remote. These portlets are ready to be used by a portal hosted on a portal server
running on a different machine. We are going to see how this can be achieved using
Rational Application Developer V7. (The following activities are assumed to be carried
out in Rational Application Developer V7 running on a machine different from the one
hosting the remote portlets.)
1.
2.
3.
4.
Invoke the New Portal Project wizard using File > New > Project.
Supply the Name and click Finish to create the portal project.
The portal Configuration is opened by default by the Portal Designer.
Drag Portlet from Palette view and drop it on to the opened portal
Configuration. The Insert Portlet dialog displays.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 18 of 24
Figure 19. Insert Portlet dialog
5. Click Import remote portlet, which will launch the Select Remote Portlet
wizard.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 19 of 24
Figure 20. Select Remote Portlet wizard
6. Click New to bring up the Add WSRP Producer wizard.
7. Specify a producer host in the URL field and a producer title in the Title
field.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 20 of 24
Figure 21. Add WSRP Producer wizard
8. Click Finish. The remote portlets provided by the new producer are displayed in
the Select Remote Portlet view.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 21 of 24
Figure 22. New remote portlets
9. Select the remote portlet that is to be inserted into the local portal.
10. Click Finish.
11. In the Insert Portlet dialog, select the remote portlet. and click OK.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 22 of 24
Figure 23. Insert Portlet dialog
12. The remote portlet is inserted into the local portal page. Note that the remote
portlets are displayed with an RP: prefix (stands for remote portlet), for example:
RP:[charts].
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 23 of 24
Figure 24. Remote portlet on the local portal page
13. Deploy the local portlet by selecting Run on Server to see the remote portlet
running inside the local portal.
Other articles in this series
Check the One-stop guide to portal and portlet application development using Rational
Application Developer V7 and WebSphere Portal V6 for summaries of the nine other
articles in this series and links to download each of them in PDF format. Topics covered
include the predevelopment resources, portlet tooling features, portal design tools, and
the testing, deploying, and debugging capabilities of Rational Application Developer.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Advanced portlet development with Rational Application Developer V7, Page 24 of 24
Resources
Learn
•
•
•
•
•
Discuss
•
Get information on IBM Rational Application Developer and how to use it:
o What's new in IBM Rational Application Developer V7.0
o IBM Rational Application Developer Version 7.0 Information Center
o Rational Application Developer page on IBM® developerWorks®
An introduction to WSRP at Introduction to Web Services for Remote Portlets
For product documentation for various offerings of WebSphere Portal, visit
the IBM WebSphere Portal Version 6.0 Information Center
Visit the Rational page on developerWorks to find technical resources and
learn about best practices for the Rational Software Delivery Platform.
Subscribe to The Rational Edge weekly newsletter.
Participate in the Rational Software Architect, Data Architect, Software
Modeler, Systems Developer, Application Developer and Web Developer
forums and the WebSphere Portal forum, where you can ask questions, share
your experiences, and discuss problems and solutions.
Download
• Get the evaluation version of Rational Application Developer for WebSphere.
• Get evaluation versions of WebSphere software.
About the author
Jaspreet Singh is a software developer and technical lead for the portal tooling
component of Rational Application Developer in the WPLC (Workplace, Portal and
Collaboration software) group at IBM India Software Labs in Delhi, India. He is an
Electronics and Communications Engineer graduate of Netaji Subhash Institute of
Technology, in Delhi, with nearly seven years of experience in IT. Since joining IBM, he
has worked mainly on Java and related technologies. When not working on portlets and
portals, he loves watching soccer and playing musical instruments.
Copyright © 2007, IBM® Corporation. All rights reserved. Published by IBM® developerWorks®.
Fly UP