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
Development Steps

Implementing Portlet Help

You can easily implement help for a custom portlet. If you implement help for a portlet, then a help icon Icon for portlet help appears in the portlet's title bar. When a user clicks the icon, the portlet help appears in a resizable, scrollable window that is by default 400 pixels wide and 200 pixels high, as shown in this example:

Example of portlet help

To implement portlet help, use these steps:

  1. Create an action class to display the JSP page for the help (or, if you want, you can use an instance of com.sas.portal.portlet.JspPortlet). Here is an example of a custom action class to display portlet help:

    package com.sas.portal.portlets.welcome;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.sas.portal.portlet.HTMLPortletAction;
    import com.sas.portal.portlet.PortletContext;
    
    public class HelpAction extends HTMLPortletAction {
         public String service(HttpServletRequest request, 
                   HttpServletResponse response, PortletContext context)
              throws Exception {
                   return "help.jsp";
         }
    } 
    
  2. Create a JSP page that contains the help text. The JSP page must have the following characteristics:

    • The JSP page must be an HTML fragment; that is, it must not contain starting and ending <HTML>, <HEAD>, or <BODY> tags.

    • The JSP page must have the file name help.jsp.

    The example JSP page for the help window that was shown previously consists of just one line:

    <em>This</em> is an example of <b>Portlet provided</b> help.
    
  3. In the portlet's deployment descriptor (XML) file, add a <portlet-action> element for the action class. Set the element's help attribute to "true,".

    Here is an example of the <portlet-action> element for a portlet that uses a custom action to display its help:

    <portlet-action name="help" help="true">
         <type>com.sas.portal.portlets.welcome.HelpAction</type>
    </portlet-action>

    Here is an example of a <portlet-action> element for a portlet that uses an instance of com.sas.portal.portlet.JspPortlet to display its help:

    <portlet-action name="help" help="true"> 
         <type>com.sas.portal.portlet.JspPortlet</type>
    </portlet-action>