Datasheet
Portlet Declarations
This is the first part of the declaration of one portlet. In this, we give it a description, a local name, a display
name, and a class name. The description and display name are meant to make it more human-friendly,
while the local name and the class actually provide the nuts and bolts required to programmatically load
and reference the portlet. The local name must, of course, be unique within the portlet application.
<portlet>
<description>Example of creating a portlet</description>
<portlet-name>ExamplePortlet</portlet-name>
<display-name>Example Portlet</display-name>
<portlet-class>org.opensourceportals.samples.ExamplePortlet</portlet-class>
The expiration-cache tag represents the number of seconds a portlet is kept in cache. The expiration
cache value of
-1 means that the portlet will always be kept in cache. If the value were zero, it would be
just the opposite — never cached.
<expiration-cache>-1</expiration-cache>
This next section declares the supported portlet modes and mime types. For each mime type, the sup-
ported portlet modes are listed. Wild cards (*) are acceptable in describing a mime type. For example, all
text-based mime types could be specified as
text/*, and all mime types could be expressed as */*. In
this case, the portlet supports traditional HTML with three different modes available:
VIEW, EDIT, and
HELP. However, it supports the VIEW mode only when the content type is the Wireless Markup
Language (WML). Each of these definitions must be unique — that is, you cannot define multiple sup-
ports blocks for the same MIME type.
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
<supports>
<mime-type>text/wml</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
This portlet provides only one Locale, English, for its internationalization support. It could support
many locales, and it would list them all here. For more information, examine Java’s internationalization
support.
<supported-locale>EN</supported-locale>
This element (<portlet-info>) provides the metadata about the portlet. The title element represents the
title that will be displayed on the portlet. The short title provides an abbreviated way of referencing the
portlet, such as in a management console. Similarly, the keywords are meant to provide context about
the subject of the portlet. This portlet information could have also been referenced in a
ResourceBundle,
with only the name of the
ResourceBundle specified here.
29
The Java Portlet API (JSR 168)
04 469513 Ch01.qxd 1/16/04 11:04 AM Page 29