SAS 9.1.3 Integration Technologies » SAS Web Infrastructure Kit: Developer's Guide


Developing Custom Portlets
Development Steps
Creating a Deployment Descriptor
Creating Display Resources Files
Developing the Presentation JSP Page
Creating Action Classes
Implementing Portlet Help
Creating a PAR File
Use Cases
Simple Display Portlet
Localized Portlet
Portlet Template (Editable Portlet)
Remote Portlet
Tips and Best Practices
Using the Portlet API
Sample Portlets
Localized Display Portlet (Welcome)
Interactive Form Portlet (FormExample)
Portlet Template, or Editable Portlet (DisplayURL)
Web Application (HelloUserWikExample)
Remote Portlet (HelloUserRemote
Portlet
Use Cases

Creating a Simple Display Portlet

The simplest kind of portlet is a JSP page that displays text, data, and images, with no interactive capabilities.

You might have existing display JSP pages that you would like to deploy in the portal Web application. For example, you might have custom JSP pages (called widgets) that you created for a previous version of the SAS Information Delivery Portal Web application. Or you might have created JSP pages using another SAS product such as SAS Enterprise Guide. It is easy to implement these JSP pages as portlets.

To implement a simple JSP portlet, use these steps:

  1. Create the JSP page, if it is not already created.
  2. Create a portlet deployment descriptor file.
  3. Create a display resources file containing the portlet title and description.
  4. Pack the files into a PAR file.

Step 1: Create the JSP Page

A JSP page that you deploy as a local portlet can be as simple as the following example:

This is a simple JSP portlet.

The only requirements are as follows:

  • The JSP page must be an HTML fragment. This means it must meet the following requirements:

    • The JSP page must not contain starting and ending <HTML>, <HEAD>, or <BODY> tags.

    • The JSP page must be able to be displayed inside a table cell in an HTML document.

  • The file name must have the extension .jsp.

For more information, see Developing the Presentation JSP Page.


Step 2: Create a Portlet Deployment Descriptor File

To create a portlet deployment descriptor file for a simple display JSP portlet, use these steps:

  1. Specify the portlet name and title using the attributes of the <local-portlet> element. The name cannot contain spaces. The portlet identifier, which consists of the portlet path (defined in the portlet-path element) together with the portlet name, must be unique within the portal Web application.

  2. Optionally, specify key words for use in searching in the <keyword> element.

  3. Specify the portal Web application's default initializer, which is called JspPortletInitializer, in the initializer-type element. For this initializer, you must specify the following in the <init-param> element:

    1. display-page in the param-name sub-element

    2. the name of your JSP page in the param-value sub-element

    Note: The default initializer passes only the display-page parameter. To pass additional parameters, you would need to create your own initializer class (see Creating an Initializer Action Class).

In most cases, you can use the default settings for the remainder of the elements. For more information, see Creating a Portlet Deployment Descriptor.

Here is an example of a portal.xml file for a simple display JSP page that will run as a local portlet (that is, inside the portlet container):


<?xml version="1.0" ?>
<!DOCTYPE portlets SYSTEM "http://localhost:9090/portlet.dtd">
<portlets>
    <local-portlet name="SimpleJsp" title="SIMPLE_JSP_PORTLET">
        <keywords>
	        <keyword>example</keywords>
        </keywords>
        <initializer-type>com.sas.portal.portlet.JspPortletInitializer 
                </initializer-type>
        <init-param>
            <param-name>display-page</param-name>
            <param-value>simpleJspTest.jsp</param-value>
        </init-param>
        <content-location>content</content-location>
        <portlet-path>/sas/portlets</portlet-path>
	<portlet-actions>
            <portlet-action name="display">
                <type>com.sas.portal.portlet.JspPortlet</type>
            </portlet-action>
        </portlet-actions>
    </local-portlet>
</portlets>

Step 3: Create a Display Resources File Containing the Portlet Title and Description

Create the display resources file as follows:

  1. Use <key>=<value> statements to define text strings for portlet.title and portlet.description, as in the following example:

    portlet.title=Welcome Portlet
    portlet.description=Welcome Portlet
  2. Name the file portletDisplayResources.properties.

  3. Place the file in the /portletname/classes directory of the PAR file.

If you want the portlet title and description to be localized at the time of deployment according to the portal Web application's default locale, you can create multiple display resources files for various locales. For details, see Creating Display Resources Files.

Note: If you omit this step, the portal Web application will use the portlet's name to create a default description. In addition, the portlet deployment mechanism will send a warning message to the server log that no localized title or description can be found.


Step 4: Pack the Files into a PAR File

Use the JAR utility to compress the portlet deployment descriptor, the JSP page, and any needed support files into an archive. For information about the required directory structure, see Creating a PAR File for Deployment in the Portal.