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
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
display-page in the
the name of your JSP page in the
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">
<local-portlet name="SimpleJsp" title="SIMPLE_JSP_PORTLET">
Step 3: Create a Display Resources File Containing the Portlet Title and Description
Create the display resources file as follows:
<key>=<value> statements to define text strings for
portlet.description, as in the following example:
Name the file
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.