Oracle9iAS Portal Developer Kit (PDK)
Building Portlets Using the Java Portlet Wizard within Oracle9i JDeveloper

Last Update: March 20, 2003
Status: Production
Version: PDK Release 2, (9.0.2 and later), Oracle9i JDeveloper version 9.0.3 and later

Introduction

Once you have successfully deployed and registered the PDK samples, you can begin your portlet development quickly and easily using the Java Portlet Wizard.  The Java Portlet Wizard is an extension of Oracle9i JDeveloper and enables you to build J2EE-based (JSP, Java, Servlet) portlets in 4 easy steps.

For an overview of the features and benefits of the Java Portlet Wizard, review An Overview of Writing Portlets.  To view an animated demo (viewlet) that shows you how to build, test, and deploy portlets using the Java Portlet Wizard, review Guided Tour for Java Portlet Development Using Oracle9i JDeveloper.

Assumptions

  1. You are familiar with portlet terminology such as portlet show modes.  For an overview of portlets, review An Overview of Portlets.

  2. You are already familiar with Oracle9i JDeveloper and know how to build and deploy Java components using Oracle9i JDeveloper.  You can download Oracle9i JDeveloper from http://otn.oracle.com.

  3. You have downloaded the Java Portlet Wizard from OTN or Oracle9iAS Portal Studio.  You have also followed the install instructions to add this extension to Oracle9i JDeveloper.

Create a Portlet & Provider

This section walks you though the wizard UI.  In the Java Portlet wizard you can choose which portlet show modes (Edit, Edit Defaults, etc.) you want to implement and what implementation method (JSP, HTTP Servlet, Java class, HTML) you want to use. The wizard then creates a simple sample implementation for each of the selected modes and with any parameters and events you have added.

  1. Create a new workspace or use an existing workspace. 
    1. If creating a new workspace, also create an open empty project.
    2. If using an existing workspace, create a new project.
  2. Right-click on your new project and select New...

  3. Select Oracle9iAS Portal under the Web Tier category. Note: if you cannot find Oracle9iAS Portal, please refer to the Java Portlet Wizard installation document.

  4. Under items for Oracle9iAS Portal, select Java Portlet and click OK.

  5. The Java Portlet Wizard now appears, click Next.

  6. In step 1 of 7, provide the portlet information or use the default.

  1. Click Next.
  2. In step 2 of 7

    1. Select the implementation style for the Show page:  JSP, HTTP Servlet, Java class, or HTML file.
    2. Provide the name of the file or use the default in the File name field.  JDeveloper will create this file for you.
    3. If you want a details page for your portlet, check 'Show details page'.  Select the implementation style and filename.

  3. Repeat the above for steps 3 and 4 of 7.

  1. In step 5 of 7, you can add public parameters to your portlet.  Click on Add and enter the following into the fields.  Once complete, click on Next.
    1. Name:  param1
    2. Display Name:  My Portlet Parameter
    3. Description:  This parameter displays a value.

  1. In step 6 of 7, you can map parameters to events.  Do nothing for this step.  Click on Next.
  2. In the last step, enter the provider name and make sure all the fields are checked.  Once you click Finish,  the deployment properties file (<providername>.properties), the provider definition file (provider.xml), the web.xml, and index.jsp will be created within this project.

  1. Click on Finish.  You should now see the following within your project:
    1. Files that represent each show mode selected.
    2. provider.xml
    3. web.xml
    4. index.jsp
    5. _default.properties
    6. <providername>.properties

    Note:  all of the above files are required for the portlet to be deployed and run successfully except for the index.jsp which is used by Oracle9i JDeveloper for testing purposes.

Add Portlet Logic

Now that you have created the default implementation you would normally extend the sample code with your business logic to implement the functionality you want.  For the purposes of this article, you will move straight to testing your provider and portlet from within Oracle9i JDeveloper.

Test Portlet and Provider

This section describes how to test your portlet and provider using the OC4J embedded within Oracle9i JDeveloper. 

  1. Right-click on the index.jsp (application homepage) and select Run index.jsp.  You should now see the Oracle9iAS Portlet Application Test Page.  This page shows a list of providers for this application (only 1 at the moment) and the default URL for your application.

  2. Click on the provider listed.  You should now see the JPDK Test Page and the list of portlets within the provider (only 1).  Use the URL provided to register the provider with Oracle9iAS Portal.

    For example:  http://mymachine:8988/JavaPorletWizard-JPWArticle-context-root/providers/myjpwprovider

REGISTERING THE PROVIDER

Once you have successfully tested your new provider, register the provider with Oracle9iAS Portal:

  1. Click Builder in the top right hand corner of the Oracle9iAS Portal Home Page, then click Register a Portlet Provider in the Provider portlet.

  2. Enter the following provider information:

    1. Name:  MyJPWProvider.

    2. Display Name:  My Java Portlet Wizard Provider.

    3. Timeout:  100.

    4. Timeout Message:  My Java Portlet Wizard Provider Timed Out.

    5. Implementation Style:  Web.

    6. Provider Login Frequency:  Never.

    7. URL:  The registration URL is:

    http://mymachine:8988/JavaPorletWizard-JPWArticle-context-root/providers/myjpwprovider

Add Portlet to a Page

When you have registered your provider you can add your new portlet to a page. Please refer to the Oracle9iAS Portal online documentation for more information.  You have now successfully built your own portlet using Oracle9i JDeveloper and the Java Portlet Wizard.

Deploy to Application Server

Now that you have successfully displayed your portlet on a page, you should deploy your application to your application server.  For more information on deploying an application, review to the Oracle9i JDeveloper documentation.

Summary

You can now go back to Oracle9i JDeveloper and update the portlet by adding features and more functionality.  You can also add portlets to the provider by right-clicking on provider.xml and selecting "Add portlet".

 

Revision History:
Revision No Last Update
Created July 30, 2002
1.0 March 20, 2003

Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065, USA
http://www.oracle.com/
Worldwide Inquiries:
1-800-ORACLE1
Fax 650.506.7200
Copyright and Corporate Info