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
Sample: Portlet Template, or Editable Portlet (DisplayURL)

Step 2: Create the Portlet Deployment Descriptor

The portlet deployment descriptor is an XML file that provides all of the information that the portal Web application needs to deploy one or more portlets. Here is the portlet deployment descriptor for the DisplayURL portlet. The boxes contain explanatory comments. For more information, see Creating a Portlet Deployment Descriptor.

<?xml version="1.0" encoding="UTF-8"?>

The DOCTYPE statement must be present in the descriptor file in order for the portlet to run. However, the document type definition (DTD) does not need to be accessible at the URL that the statement specifies.

If you want to look at the portlet.dtd file, you can find it in the portal setup directory in the path Portal\WEB-INF. For example, if you used the default installation location on a Windows system, then the DTD is located under the following path: c:\Program Files\SAS\Web\Portal2.0.1\Portal\WEB-INF.

<!DOCTYPE portlets SYSTEM "http://www.sas.com/idp/portlet.dtd">

<portlets>

In the local-portlet element, the value of the title attribute specifies the new portlet type that will be displayed to users in the Create a New Portlet dialog box.

The attribute editorType="portlet" indicates that portlets created from the template are to be editable. When this attribute value is specified, then a portlet action with the attribute editor="true" must also be specified. Otherwise, the portlet deployer will send a warning to the server log and will not deploy the portlet.

Note: Add the word "Sample" to the name and title in order to distinguish this portlet from the URL Display portlet that is delivered with the portal.

<local-portlet name="DisplayURL Sample" title="URL Display Portlet Sample"
  editorType="portlet">
  <localized-resources locales="en,de,es,fr,it,ja,pl,ru,sv,zh_CN" />
The deployment element includes the attribute value userCanCreateMore="true". This value indicates that the portlet is a template and can be replicated by portal users.

  <deployment scope="user" autoDeploy="false" 
     userCanCreateMore="true" />
  <initializer-type>
     com.sas.portal.portlets.displayurl.Initializer
  </initializer-type>
  <init-param>
    <param-name>error-page</param-name>
    <param-value>Error.jsp</param-value>
  </init-param>
  <init-param>
    <param-name>display-page</param-name>
    <param-value>Viewer.jsp</param-value>
  </init-param>
  <init-param>
    <param-name>edit-page</param-name>
    <param-value>Editor.jsp</param-value>
  </init-param>
  <error-handler>
    <type>com.sas.portal.portlets.displayurl.ErrorHandler</type>
  </error-handler>
  <portlet-path>/sas/portlets</portlet-path>
  <portlet-actions>

This action element specifies the action class DisplayAction. The attribute default="true" indicates that this is the default action class, which means that the class is to be invoked before the portlet's JSP renders.

    <portlet-action name="display" default="true" >
      <type>
        com.sas.portal.portlets.displayurl.DisplayAction
      </type>
    </portlet-action>

This action element specifies the action class EditorAction. The attribute editor="true" indicates that this action is to be invoked when a user clicks the portlet's Edit icon.

    <portlet-action name="editor" editor="true" >
      <type>
        com.sas.portal.portlets.displayurl.EditorAction
      </type>
    </portlet-action>

The following action elements specify the action classes that will be invoked when the user clicks the OK button and the Cancel button on the editor display page.

    <portlet-action name="ok" default="false" >
      <type>com.sas.portal.portlets.displayurl.OKAction</type>
    </portlet-action>
    <portlet-action name="cancel" default="false" >
      <type>com.sas.portal.portlets.displayurl.CancelAction</type>
    </portlet-action>
  </portlet-actions>
</local-portlet>
</portlets>