Sample: Localized Display Portlet (Welcome Portlet)
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 Welcome portlet. The boxes contain explanatory comments. For more information, see Creating a Portlet Deployment Descriptor.
<?xml version="1.0" encoding="UTF-8"?>
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
If you want to look at the
portlet.dtd file, you can
find it in the portal setup directory in the path
For example, if you used the default installation location
on a Windows system, then the DTD is located under the
<!DOCTYPE portlets SYSTEM "http://www.sas.com/idp/portlet.dtd">
local-portlet element assigns the name
Welcome to the portlet. 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.
icon attribute is optional. It specifies the icon that is to appear with the portlet's name in the portal Web application's search results. In the portlet's directory structure, the icon's image file must be placed in or under the
content directory. If it is in a subdirectory of
content, you must specify the subdirectory with the image name. For example, if the image
greeting.gif is in the path
content\icons, then you would specify
If an icon is not specified, then the default icon for portlets will be used.
<local-portlet name="Welcome Sample" title="Welcome Sample" icon="Portlet.gif">
localized resources element lists the locales that the portlet supports. Display resource files must be provided for each of these locales.
<localized-resources locales="de,en,es,fr,it,ja,pl,ru,sv,zh_CN" />
deployment element specifies that the portlet is to be available to the Public group. This means that all users will be able to search for this portlet and add it to their pages. Use all CAPS for PUBLIC.
<deployment scope="group" autoDeploy="true" userCanCreateMore="false">
Since the Welcome portlet does not need its own initializer class, the portal Web application's default portlet initializer (
JspPortletInitializer) is specified. This class requires a parameter called
display-page. The initializer places the value of this parameter in the
PortletContext object so that it can be used by the portlet's action class. The value of the parameter is the name of the Welcome portlet's JSP page, called
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).
portlet-path element specifies the directory location in which the portlet is to be deployed. The portlet identifier, which consists of the portlet path together with the portlet name (defined in the
local-portlet element), must be unique within the portal Web application. For example, Orion Star Sports & Outdoors could have two Welcome portlets if different paths are specified for each (as in
|To provide for internationalization of the text that appears inside the portlet border, the Welcome portlet has its own action class, called |
WelcomeAction. The name of the class is specified in the
type subelement of the
<portlet-action name="display" default="true">