|
Developing Custom Portlets
Developing Custom Portlets
A portlet is a Web component that is managed by a Web application and aggregated with other portlets to form a page within the application. A portlet processes requests from the user and generates dynamic content such as report lists, alerts, workflow notifications, or performance metrics. The components that are needed to implement a portlet may include JSP pages, custom classes, and associated resources.
Portlets that are created with the SAS Web Infrastructure Kit have a standard appearance, which includes a title bar that contains links or icons to portlet actions, as shown in this example:
The framework of the SAS Web Infrastructure Kit makes it easy for you to quickly develop and deploy custom portlets that meet your organization's needs. This framework, which is based on the Struts architecture and conforms to industry-standard Model-Viewer-Controller (Model 2) design patterns, provides the following:
an execution environment that allows portlets to execute in the portlet container, in the same way that servlets execute in the servlet container. The portal Web application processes all HTTP requests for portlets, while the portal Web application's session and state information are maintained and shared among portlet actions and across requests.
support for portlets running remotely in other Web technology frameworks, with the option to pass the portal Web application's session and state information to these portlets.
simplified portlet deployment through the use of the following:
a portlet deployment descriptor, which is an XML file that specifies the portlet's actions as well as initialization, path, and access control information.
a portlet archive (PAR) file, which includes all of the elements needed to deploy a portlet or series of portlets, including the portlet deployment descriptor, JSP pages, custom Java classes, and associated resources (such as images, resource bundles, HTML files, and style sheets).
a set of action and initializer classes, which reduce the need for developing custom programs. These classes perform the most commonly used functions, such as displaying the JSP page that is specified in the portlet deployment descriptor.
access to SAS custom tags and to tags in the Struts development framework to simplify development of JSP pages for your portlets.
a dynamic (or "hot") deployment mechanism that enables new portlets to be deployed without the need to restart the Web server.
Options for Implementing Portlets
The action and initializer classes included in the SAS Web Infrastructure Kit are designed to handle a portlet's basic function of displaying a single JSP page. However, to meet specialized needs you can do the following:
write one or more Java classes that implement the com.sas.portal.portlet.PortletActionInterface . Alternatively, you can extend com.sas.portal.portlet.HTMLPortletAction to obtain a basic implementation of the interface.
write Java classes that implement the PortletInitializerInterface , ErrorHandlerInterface , or PostProcessorInterface in the com.sas.portal.portlet package in order to meet more specialized requirements.
For more information, see the Portlet API and the sample portlets.
Best Practices
The following is a summary of best practices for developing portlets for deployment in the portal Web application:
-
To avoid namespace problems, use a standard naming convention
for portlet paths. The portlet namespace is comprised
of the path (with leading underscores in place of slashes)
and the portlet's name. For example, a portlet with the
name simpleJSP and a path of /sas/portlets
would be deployed as _sas_portlets_simpleJSP .
-
Deploy new portlets into a staging area (that is, a test
installation of the portal Web application) for verification
and testing before deploying them into the production
environment.
For remote portlets, use the portlet's direct URL to test
and debug the portlet before you deploy it into the portal
Web application.
|