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:
- Create the JSP page, if it is not already created.
- Create a portlet deployment descriptor file.
- Create a display resources file containing the portlet title and description.
- 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:
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:
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.
Optionally, specify key words for use in searching in the <keyword> element.
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:
display-page in the param-name sub-element
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:
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
Name the file portletDisplayResources.properties .
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.
|