Datasheet
Other Elements of the Java Portlet API
Now that you have examined the high-level concepts of the Portlet API, this section addresses the lower-
level components within the specification, providing a portlet developer’s perspective on the internals
of the specification, highlighting important concepts and potential pitfalls.
PortletConfig
When a portlet is initialized, it needs access to the initialization parameters and other configuration infor-
mation. The
PortletConfig object provides these. In addition to init parameters, the PortletConfig
object can also expose a ResourceBundle for the portlet.
The
ResourceBundle contains certain fields required by the specification, including title, short title, and
keywords. A
ResourceBundle allows for easier localization of your portlet application.
You can specify the
ResourceBundle inline in the portlet application deployment descriptor, as follows:
<portlet>
...
<portlet-info>
<title>Homer’s D’oh a Day Portlet</title>
<short-title>doh</short-title>
<keywords>Simpsons, Homer Simpson, Entertainment</keywords>
</portlet-info>
...
</portlet>
Alternatively, you can specify a reference to a ResourceBundle this way:
<portlet>
...
<portlet-info>
<resource-bundle>com.somedomainname.HomerPortlet</resource-bundle>
</portlet-info>
...
</portlet>
Whichever method you use (the first is better mostly for applications with minimal localization require-
ments), the net effect for the developer is the same. These properties are always created in a
Resource
Bundle
and made available through the PortletConfig object.
PortletURL
When building portlet content, it is necessary to build URLs that provide the capability to call the portal.
This is the foundation of making the portal interactive. In order to allow for the proper creation of a
PortletURL, there are two implementations: ActionURL and RenderURL. Both of these are created from
the
RequestResponse interface using the createActionURL and createResponseURL methods,
respectively. The
ActionURL provides the capability to issue action requests on the portal, to do things
such as change portlet mode, change window state, submit a form, and so on. The
RenderURL provides
the capability to skip the portlet’s
processAction method and merely invoke the render method,
passing
render parameters to control presentation.
14
Chapter 1
04 469513 Ch01.qxd 1/16/04 11:04 AM Page 14