Skip Headers
Oracle® WebCenter Framework Tutorial
10g (10.1.3.2.0)

Part Number B31072-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

6 Making Portlets Communicate

In this lesson you'll add two portlets to a page and learn how to configure them so that one portlet drives the content of the other. To demonstrate inter-portlet communication, you'll use a Parameter Form Portlet (one of the sample WSRP 2.0 portlets) and an instance of OmniPortlet (an Oracle PDK portlet). Both portlets are available through the preconfigured OC4J you installed in Chapter 3, "Building and Testing Your First Portlet".

Figure 6-1 illustrates what the page (called MyWeather.jspx) will look like at the end of the lesson.

Figure 6-1 MyWeather.jspx at the End of Lesson 6

Successfully Registered WSRP Portlet Producer
Description of "Figure 6-1 MyWeather.jspx at the End of Lesson 6"

Introduction

You'll make two portlets communicate in the following steps:

Prerequisites

Both of the portlets we use in this lesson are available through the WebCenter Preconfigured OC4J (installed and initialized during Chapter 3 Step 2: Setting Up Your Connection). If this OC4J instance is no longer running, click the Start WebCenter Preconfigured OC4J icon at the far right of the JDeveloper toolbar before you begin this lesson.

Step 1: Registering Portlet Producers

Before you can add a portlet to a page, you must register its producer with the WebCenter application. For this lesson you'll need to register producers for the following portlets:

Let's start with the Parameter Form Portlet producer:

  1. Check that the Parameter Form Portlet producer is up and running. In a browser, enter the following producer test page URL:

    http://localhost:6688/portletapp/info

    If the producer is up and running, you should see a WSRP Producer Test Page displaying two WSRP producer registration URLs (WSDL documents). You'll use the WSRP v2 WSDL URL in this WebCenter application:

    http://localhost:6688/portletapp/portlets/wsrp2?WSDL

    Now, let's register the producer with your application.

  2. Right-click Portlet Producers in the Applications Navigator, and click New WSRP Producer.

  3. When the WSRP Portlet Producer Registration Wizard displays, click Next to move beyond the Welcome page.

  4. In the Name field, enter: SampleWSRPPortletsProducer

  5. Click Next.

  6. On the Connection page, enter the producer's URL Endpoint.

    To produce the Parameter Form portlet through the WebCenter Preconfigured OC4J, enter the following URL:

    http://localhost:6688/portletapp/portlets/wsrp2?WSDL

    This tutorial assumes that localhost can be used in a URL to refer to the local computer on which your preconfigured OC4J installation resides. (If this is not the case, replace localhost with your computer's IP address.)

    Proxy information isn't necessary as we're using a local preconfigured OC4J. Make sure that the Use proxy option is unchecked.

  7. Click Next.

  8. On the Registration Details page, accept the default timeout value of 30 seconds, and click Finish. For this tutorial, there is no need to set any of the advanced options.

    You should see the following message (Figure 6-2):

    Figure 6-2 WSRP Portlet Producer Registration Successful

    Successfully Registered WSRP Portlet Producer
    Description of "Figure 6-2 WSRP Portlet Producer Registration Successful"

  9. Click OK to close the message box.

    The new producer appears in the Applications Navigator, under the section Portlet Producers (Figure 6-3).

    Figure 6-3 Successfully Registered Producer for the Sample WSRP Portlets

    Successfully Registered WSRP Portlet Producer
    Description of "Figure 6-3 Successfully Registered Producer for the Sample WSRP Portlets"

    Open the Component Palette through the View menu, and expand its drop-down list. Locate and select SampleWSRPPortletsProducer from this list. Several portlets are available for selection. Among these, you will find the Parameter Form Portlet, which you will use in this lesson. (If you can't see anything in the Component Palette, try displaying a Java Server Faces page in Design view, such as MyPage.jspx. This should reveal all the portlets).

    You'll come back to the Parameter Form Portlet later. First you must register the OmniPortlet producer.

  10. First, check that the OmniPortlet producer is up and running. In a browser, enter the following producer test page URL:

    http://localhost:6688/portalTools/omniPortlet/providers/omniPortlet

    If the producer is available, you'll see the OmniPortlet's Producer Test Page.

    Now, let's register the OmniPortlet producer. So far in this tutorial you've registered only WSRP producers. As OmniPortlet is an Oracle PDK portlet, you'll be using a different wizard to register this producer.

  11. Right-click Portlet Producers in the Applications Navigator, and click New Oracle PDK Producer.

  12. When the PDK Portlet Producer Registration Wizard appears, click Next.

  13. In the Name field, enter: OmniPortletProducer

  14. Click Next.

  15. On the Connection page, enter the producer's URL Endpoint.

    To produce OmniPortlet through the WebCenter Preconfigured OC4J, enter the following URL:

    http://localhost:6688/portalTools/omniPortlet/providers/omniPortlet

    This tutorial assumes that localhost can be used in a URL to refer to the local computer on which your preconfigured OC4J installation resides. (If this is not the case, replace localhost with your computer's IP address.)

    Make sure that the Use proxy option is unchecked.

  16. Click Finish.

    You should see the following message (Figure 6-4):

    Figure 6-4 Oracle PDK Portlet Producer Registration Successful

    Successfully Registered PDK Portlet Producer
    Description of "Figure 6-4 Oracle PDK Portlet Producer Registration Successful"

  17. Click OK to close the message box.

    Both producers should now appear in the Applications Navigator, under the section Portlet Producers (Figure 6-5).

    Figure 6-5 Successfully Registered Producer for OmniPortlet

    Applications Navigator Displays New Portlet Producers
    Description of "Figure 6-5 Successfully Registered Producer for OmniPortlet"

  18. Open the Component Palette again, and click the drop-down list to make sure that OmniPortletProducer is displayed. Select OmniPortletProducer from this list.

    Several portlets are available for selection. Among these, you'll find OmniPortlet, which you will use in this lesson.

Now both producers are registered with the tutorial application you can drop their portlets onto a page.

Step 2: Placing the Parameter Form Portlet on a Page

In this step, you'll place a Parameter Form Portlet on a page and see how JDeveloper handles a portlet with public portlet parameters. Then you'll run the page and, through portlet customization, create a portlet that invites a user to enter a ZIP code. Later on in the lesson you'll learn how to pass the ZIP code as a parameter to an OmniPortlet, where it'll be used to drive the content of a weather portlet.

Let's start by creating a brand new page called MyWeather.jspx, which you'll use to learn about inter-portlet communication.

  1. Create a new Java Server Faces page named MyWeather.jspx.

    1. In the Applications Navigator, right-click ViewController, and select New.

    2. In the Categories pane, under Web Tier, select JSF.

    3. Under Items, select JSF JSP, and click OK.

    4. Click Next to skip the Welcome page.

    5. In the File Name field, enter: MyWeather

    6. Under Type, click JSP Document, and then click Next.

    7. Choose Automatically Expose UI Components in a New Managed Bean, and then click Next.

    8. On the Tag Libraries page, make sure the following libraries appear in the Selected Libraries pane:

      ADF Faces Components 10_1_3_2_0

      ADF Faces HTML 10_1_3_2_0

      ADF Portlet Components 10_1_3_2_0

      Customizable Components Core 10_1_3_2

      JSF Core 1.0

      JSF HTML 1.0

    9. There is no need to set any other options, so click Finish on this page.

    MyWeather.jspx should open in the Visual Editor (Figure 6-6), ready for us to begin adding portlets.

    Figure 6-6 Empty MyWeather.jspx

    Empty MyWeather.jspx
    Description of "Figure 6-6 Empty MyWeather.jspx"

  2. Add a panelCustomizable component to your page. You'll use this component to house both of your portlets (Parameter Form Portlet and OmniPortlet) and to provide horizontal/vertical layout.

    1. Open the Component Palette.

    2. Scroll to the listing for Customizable Components Core (Figure 6-7).

      Figure 6-7 Component Palette - Customizable Components Core

      Component Palette Displays Customizable Components Core
      Description of "Figure 6-7 Component Palette - Customizable Components Core"

    3. Select PanelCustomizable, and drag it over the h:form tag in the Structure window.

      The panelCustomizable component should display at the top of the page (Figure 6-8).

      Figure 6-8 MyWeather.jspx - PanelCustomizable Component

      PanelCustomizable Component
      Description of "Figure 6-8 MyWeather.jspx - PanelCustomizable Component"

      The panelCustomizable component must be placed inside the h:form for the page. Take a look in the Structure window to check that the frame is placed inside the form. Remember, you don't need add a showDetailFrame because portlets come automatically equipped with the customization capabilities; that is, the ability to maximize/minimize and to reposition the portlet on the page.

  3. Now you're ready for the Parameter Form Portlet. From the Component Palette, select SampleWSRPPortletsProducer.

  4. Select Parameter Form Portlet, then drag and drop it on top of the cust:panelCustomizable component in the Structure window.

    The Visual Editor should look like Figure 6-9.

    Figure 6-9 MyWeather.jspx - Parameter Form Portlet Inside a panelCustomizable

    Description of Figure 6-9 follows
    Description of "Figure 6-9 MyWeather.jspx - Parameter Form Portlet Inside a panelCustomizable"

    Before you run the page, let's take a look at the underlying page definition to see how JDeveloper responds to a portlet with built-in parameters like this one.

    Right-click MyWeather.jspx in the Applications Navigator, and choose Go to Page Definition. Click Yes if the Page Definition doesn't exist yet.

    In the Structure window (Figure 6-10) you should see an entry for each of the Parameter Form's portlet parameters (ora_wsrp_navigparam_Parameter1, ora_wsrp_navigparam_Parameter2 and ora_wsrp_navigparam_Parameter3). You should also see three page variable entries with corresponding names and the prefix <portletname_n_> —in this case, ParameterFormPortlet1_1_).

    Figure 6-10 MyWeatherPageDef.xml - Parameter Form Portlet Parameters

    Structure Window - MyWeatherPageDef.xml
    Description of "Figure 6-10 MyWeatherPageDef.xml - Parameter Form Portlet Parameters"

    When a portlet is dropped on a page, JDeveloper checks to see if the portlet has public portlet parameters and, if it does, automatically adds the corresponding number of page variables and maps them to the portlet parameters.

    Use the Property Inspector to examine one of the mappings. You should see that ora_wsrp_navigparam_Parameter1, for example, is mapped to the page variable named ParameterFormPortlet1_1_ora_wsrp_navigparam_Parameter1 (Figure 6-11).

    Figure 6-11 Property Inspector - Portlet Parameter Mapped to Page Variable

    Property Inspector - ora_wsrp_navigparam_Parameter1
    Description of "Figure 6-11 Property Inspector - Portlet Parameter Mapped to Page Variable"

    Now let's run the page to see what a default Parameter Form Portlet looks like.

  5. First, save all your changes. Click the Save All icon on the JDeveloper toolbar.

  6. In the Applications Navigator, right-click MyWeather.jspx, and choose Run.

    The default Parameter Form Portlet displays in your browser (Figure 6-12).

    Figure 6-12 Default Parameter Form Portlet

    Default Parameter Form Portlet
    Description of "Figure 6-12 Default Parameter Form Portlet"

    As you can see, the initial version of the portlet displays some default text. In the next step, you'll customize the portlet so that it invites users to enter a US ZIP code. Remember, the purpose of this lesson is to work with this portlet so it will accept a parameter value (such as a ZIP code) and pass it to another portlet.

Step 3: Customizing the Parameter Form Portlet

In this step you'll customize the Parameter Form Portlet by changing its title and prompts. You'll also hide unwanted parameters. The Parameter Form Portlet provides three parameter but this tutorial requires only one to demonstrate parameter passing between portlets.

  1. Display the portlet in a browser, then click the Actions icon in the portlet header.

  2. Click the menu option Customize.

  3. Change the Title to: Enter a ZIP code here:

  4. For Parameter 1 Prompt, enter: ZIP Code:

  5. You don't need the second and third parameters, so you can hide them. To do this, remove the default prompt text taking care not to leave behind any spaces.

    The Customize options should now look something like Figure 6-13.

    Figure 6-13 Parameter Form Portlet Customization Options

    Customize Parameter Form portlet
    Description of "Figure 6-13 Parameter Form Portlet Customization Options"

  6. Click OK.

When displayed in the browser, the portlet should look like Figure 6-14.

Figure 6-14 Customized Parameter Form Portlet

Customized Parameter Form Portlet
Description of "Figure 6-14 Customized Parameter Form Portlet"

Before moving on to the next step, let's review what you've built so far. First, you created a page called MyWeather.jspx, and added a single Parameter Form Portlet. Then, through portlet customization, you set up one of its parameters, ora_wsrp_navigparam_Parameter1, to accept a US ZIP code. You may recall that JDeveloper automatically mapped this particular parameter to a page variable named ParameterFormPortlet1_1_ora_wsrp_navigparam_Parameter1. Later on, you'll use this variable to pass the ZIP code on to another portlet.

But first, let's add the second portlet—an OmniPortlet.

Step 4: Placing an OmniPortlet on a Page

In this step you'll place an OmniPortlet under the Parameter Form Portlet.

  1. Display MyWeather.jspx in JDeveloper. In the Applications Navigator, right-click MyWeather.jspx, and click Open.

  2. Open the Component Palette, and locate OmniPortletProducer.

  3. Select OmniPortletProducer.

  4. Select OmniPortlet, and drag it over cust:PanelCustomizable in the Structure window.

    The Visual Editor should now look like Figure 6-15.

    Figure 6-15 MyWeather.jspx - OmniPortlet Added To PanelCustomizable

    Visual Editor Showing OmniPortlet Added to MyWeather Page
    Description of "Figure 6-15 MyWeather.jspx - OmniPortlet Added To PanelCustomizable"

    The Structure window should look like Figure 6-16.

    Figure 6-16 Structure Window - Displays New OmniPortlet

    Structure Window Showing New OmniPortlet
    Description of "Figure 6-16 Structure Window - Displays New OmniPortlet"

  5. Let's take another look at the underlying page definition. Right-click MyWeather.jspx in the Applications Navigator, and choose Go to Page Definition.

    In the Structure window (Figure 6-17), you'll see a new entry for OmniPortlet. This portlet has five portlet parameters (Param1 - Param5), and they too have been automatically mapped to page variables OmniPortlet1_1_Param1OmniPortlet1_1_Param5.

    Figure 6-17 MyWeatherPageDef.xml - OmniPortlet Portlet Parameters

    Structure Window Showing OmniPortlet Parameters
    Description of "Figure 6-17 MyWeatherPageDef.xml - OmniPortlet Portlet Parameters"

    In Step 6: Configuring the Portlets Together you'll use these portlet parameters to configure inter-portlet communication. But first, let's see what an OmniPortlet portlet looks like.

  6. First, save all your changes. Click the Save All icon on the JDeveloper toolbar.

  7. Before running the page again, stop the embedded OC4J Server. Choose Run, Terminate, Embedded OC4J Server from the main menu.

    Alternatively, click the red square Terminate icon in the Embedded OC4J Server Log window.

  8. In the Applications Navigator, right-click MyWeather.jspx, and choose Run.

    OmniPortlet displays in the browser underneath the Parameter Form Portlet (Figure 6-18).

    Figure 6-18 Default (Blank) OmniPortlet

    Blank OmniPortlet
    Description of "Figure 6-18 Default (Blank) OmniPortlet"

    As you can see, the initial version of the portlet is blank. In the next step you'll use OmniPortlet to build a weather portlet based on a Web Service.

Step 5: Building an OmniPortlet That Uses a Web Service

As one of the most versatile portlets, OmniPortlet can publish data from a variety of data sources using a variety of layouts. In this step you will build a weather portlet based on a Web Service.

Note:

If you are working behind a firewall, some additional configuration is required to access the Weather Web Service. Specifically, you will need to add HTTP proxy details to the <proxyInfo> tag in your Omniportlet producer's provider.xml file. This file is located at:

JDEV_HOME\jdev\extensions\oracle.adfp.seededoc4j.10.1.3.2.\j2ee\home\applications\portalTools\omniPortlet\WEB-INF\providers\omniPortlet

When making changes to the provider.xml file, the portlet producer must be refreshed on the WebCenter application side. To update the proxy details and refresh the portlet producer, perform the following steps:

  1. Stop the WebCenter application (consumer).

  2. Update the provider.xml file and save your changes.

  3. In Oracle JDeveloper, refresh the portlet producer on the WebCenter application (consumer) side.

  4. Redeploy the WebCenter application.

For more information, see topic titled "B.2.1 Configuring the OmniPortlet Producer to Access Data Outside a Firewall" in Oracle WebCenter Framework Developer's Guide.

  1. Display MyWeather.jspx in a browser. In the Applications Navigator, right-click MyWeather.jspx, and choose Run.

  2. In the browser, click the Define link to start the OmniPortlet wizard.

  3. Choose Web Service, and click Next.

    After you finish this tutorial, you'll probably want to learn how to use other data sources with OmniPortlet, such as spreadsheets (character-separated values), XML, and even application data from existing Web pages. All of these options are described in the Oracle WebCenter Framework Developer's Guide.

  4. Enter the WSDL URL of a demonstration weather Web Service available through Oracle Technology Network at:

    http://webservices.oracle.com/WeatherWS/WeatherWS?WSDL

    This Web Service has one method (WeatherWS.giveMeSomeWeatherInfo) and accepts one parameter (param0). When you pass a valid US ZIP Code through param0, the Web Service returns weather information for the area specified.

    Note: This Web Service does not return live weather information. It is useful for demonstration purposes only.

  5. To access this method parameter, click Show Methods.

    A parameter labeled param0 should display on the page.

  6. Enter ##Param1## in the param0 parameter field.

    This tells the Web Service to accept values from the Omniportlet parameter Param1. Later on, you'll map portlet parameter Param1 to a page variable named ParameterFormPortlet1_1_ora_wsrp_navigparam_Parameter1, see Step 6: Configuring the Portlets Together.

  7. Under Portlet Parameters, set a Default Value for Param1. Enter: 94065

    This tells the Web Service to return weather information for ZIP code 94065 (Redwood City, CA) by default.

  8. Click Next, and then Next again as you don't need to set any filter options.

  9. On the View Page, enter the values shown in Table 6-1.

    Table 6-1 OmniPortlet View Page Settings

    Settings Value

    Title

    Enter a title for the portlet: Weather Forecast

    Header Text

    Display the current value of Param1 (current ZIP code) in the portlet header. Enter: For ZIP Code ##Param1##


  10. Click Next, then specify the Column Label, Column, and Display As properties for the weather data as shown in Table 6-2.

    Table 6-2 Column Properties for the Weather Forecast Portlet

    Name Column Label Column Display As

    Field1

    Day

    dayOfWeek

    Text

    Field2

    Hi

    hiTemp

    Text

    Field3

    Lo

    lowTemp

    Text

    Field4

    Sky

    sky

    Text

    Field5

    (Blank)

    img

    Image


  11. Click Finish to display weather information for Redwood City. You should now see both portlets in your browser (Figure 6-19).

    Figure 6-19 OmniPortlet Displaying a Weather Web Service

    OmniPortlet Displaying a Weather Web Service
    Description of "Figure 6-19 OmniPortlet Displaying a Weather Web Service"

The Omniportlet displays a weather forecast for Redwood City, CA, which has the ZIP code 94065. The Web Service providing this data can return weather information for other areas if it is passed a valid US ZIP code. In the next step you'll learn how to link these two portlets and make the first portlet (Parameter Form Portlet) drive the content of the Omniportlet.

Step 6: Configuring the Portlets Together

In this step you'll enable inter-portlet communication between two portlets.

  1. In JDeveloper, display the page definition for MyWeather.jspx. In the Applications Navigator, right-click MyWeather.jspx, and select Go to Page Definition.

  2. Examine MyWeatherPageDef.xml through the Structure window. In the executables section you'll find:

    • ParameterFormPortlet1_1 - with three portlet parameters ora_wsrp_navigparam_Parameter1, ora_wsrp_navigparam_Parameter2 and ora_wsrp_navigparam_Parameter3

    • OmniPortlet1_1 - with five portlet parameters Param1 - Param5

    • variables - eight page variables, each mapped to a different portlet parameter. JDeveloper creates these mappings automatically when portlets (with parameters) are placed on a page

    Although each portlet supports several parameters you'll only use one from each portlet to demonstrate inter-portlet communication:

    In the next step you'll map these two parameters to the same page variable and in doing so, facilitate parameter passing between two portlets. At the moment ora_wsrp_navigparam_Parameter1 is mapped to page variable ParameterFormPortlet1_1_ora_wsrp_navigparam_Parameter1, so let's map Param1 to this page variable too.

  3. Use the Structure window to link OmniPortlet and the Parameter Form Portlet:

    1. Right-click Param1, and select Properties.

      Param1 is located under MyWeatherPageDef\executables\OmniPortlet1_1\parameters.

    2. Click Advanced Properties.

    3. From the pageVariable drop-down list, select ParameterFormPortlet1_1_ora_wsrp_navigparam_Parameter1 (Figure 6-20).

      Figure 6-20 OmniPortlet Param1 Mapped to Same Page Variable as the Parameter Form Portlet

      Mapping OmniPortlet Param1 Mapped to pageVariable1
      Description of "Figure 6-20 OmniPortlet Param1 Mapped to Same Page Variable as the Parameter Form Portlet"

    4. Click OK.

  4. Click Save All in the JDeveloper toolbar.

Now, let's run the page to see the portlets working together.

Step 7: Testing Portlet Interaction

Let's see the portlets on MyWeather.jspx working together.

  1. Before running the page again, stop the embedded OC4J Server. Choose Run, Terminate, Embedded OC4J Server from the main menu.

  2. In the Applications Navigator, right-click MyWeather.jspx, and select Run.

    Assuming there aren't any compiler errors, the page opens in a new browser window and you should see a weather forecast for the Redwood City area (ZIP Code 94065).

  3. In the ZIP Code field, enter: 10001

    This is the ZIP Code for New York.

  4. Click OK.

    The Weather Forecast portlet should change, showing weather information for New York (something like Figure 6-21).

    Figure 6-21 Portlets Show Weather for New York

    Weather for New York
    Description of "Figure 6-21 Portlets Show Weather for New York"

Congratulations! You've completed this lesson and made two portlets communicate with each other.

In the next lesson, you will learn how to publish file system content in your WebCenter application.