- The Benefits of Inter-Portlet Communication
- The WebSphere Property Broker
- Creating a Service Provider
- Testing the Service Provider
- Creating a List Portlet
- Creating a Detail Portlet
- Configuring the WebSphere Property Broker
- Alternative Communication Methods
- When to Use Inter-Portlet Communication
- Important Points
Configuring the WebSphere Property Broker
When setting up inter-portlet communication via the WebSphere Property Broker, some configuration is required to link or wire portlets together after they have been deployed. This section walks through the process of configuring the list portlet to send a loan ID to the detail portlet, which then displays details for the selected loan. At this point, note that the portlets are not wired together, so if you click on a loan in the list portlet, the details are opened within the same portlet, and the detail portlet still displays the No loan selected. message.
To configure the Property Broker, first log in to the portal as a user who has access to wire portlets together. You need a user with Privileged User access or higher to the portal page that is to contain the loan portlets. Navigate to where you added the Loan Detail and Loans List portlets and open the Page Menu for the page. You can do this in WebSphere Portal 6, for example, by moving the cursor to the right of the page title until a small arrow icon is revealed, as shown in Figure 7.14. Click the arrow to open the Page Menu, and then select Edit Page Layout.
Figure 7.14 Opening the Page menu.
Click on the Wires tab, which should be the last tab on the Page Layout page. If you can't see the Wires tab, check that you are logged in as a user with at least privileged user access to the current page. This page lets you define inter-portlet communication for the portal. You can even define communication from one page to another. Note that you only define communication for portlets that have been added to a page in the portal. In this step, you add a row to the Wires page to define the communication between the list and detail portlet.
Select Loans List from the Source portlet dropdown, and then select loanID in the Sending dropdown. These values are taken from the Cooperative Portlet Source builder call, although they can be defined using IDEs other than WPF (WPF applications can communicate with non-WPF applications, and vice-versa). The current page is automatically selected as the target page. Select Loan Detail for the Target portlet, and set the Receiving dropdown to 'Displays loan detail, loanID'. This is the action caption and input name defined in the Cooperative Portlet Target builder call.
The final drop-down box gives you a choice of creating the wire as personal or public. A personal wire is accessible only by the current user, whereas a public wire is accessible to all users. Leave the default setting and press the icon to add the wire to the portal. Wait for the page to reload and press the Done button to return to the portal.
You have now configured communication between the list and detail portlet.
Testing Inter-Portlet Communication
When you press the Done button on the Wires page, you are returned to where the list and detail portlets are displayed on the portal. To test that the communication is working correctly, click on a loan in the Loans List portlet. When the page reloads, a loan should be opened in the Loan Detail portlet, and the Loans List portlet should still display the loans list, rather than the loan detail, as it did previously. For example, clicking on 00003 should bring up loan details for The Interminable Journey, as shown in Figure 7.15.
Figure 7.15 Testing inter-portlet communication in the portal.
You have now successfully created, deployed, and tested an application consisting of inter-communicating portlets. However, the method employed in this section is only one of several ways to set up inter-portlet communication. Some alternatives to this approach are discussed in the next section.