Datasheet

You will find several methods of the PortletURL interface interesting:
setSecure — provides the capability to specify whether the URL should use HTTPS or not. If it
is not used, it continues with whatever the current request specified. Therefore, you do not have
to specify it repeatedly.
setWindowState enables you to change the window state of the portlet.
addParameter adds parameters to the URL.
toString provides a string representation of the URL. Note that it is not guaranteed to be a
valid URL, as the portal may use tokens for URL rewriting.
setPortletMode enables you to set the portlet’s mode.
Portlet Modes
A portlet mode represents a functional state of a portlet. This is used by the portlet to determine how to
manage a
render request. That is, depending on the mode, the portlet will render different markup.
Portlets are able to change their mode as part of processing action requests. In addition, a portlet can be
configured with different modes available and further restrict its availability based on role. The follow-
ing table describes the standard portlet modes defined in the Portlet API.
Mode Description
VIEW Generates markup visualizing the portlet state and properties. Developers implement
doView of GenericPortlet to provide this functionality.
EDIT Produces markup to enable modification of portlet properties. Developers implement
doEdit of GenericPortlet to provide this functionality.
HELP Provides help text for the portlet. Developers implement doHelp of GenericPortlet
to provide this functionality.
A portal can also provide custom portlet modes. Note that this is portal dependent, not portlet depen-
dent. Therefore, if a portlet implements additional portlet modes, they will not be portable between vari-
ous portlet containers. The portlet needs to override the
doDispatch method to call the appropriate
render method. For example, if you define a portlet mode called “SPECIAL”, the doDispatch method
would call its
render method, which by convention would be doSpecial. Of course, because you are
implementing the method, you could call the method anything you want.
Also note that you can specify which types of markup are available for a given portlet mode. Additional
information on configuring portal modes is presented in a later section, “Portlet Application Deployment
Descriptor.”
Portlet developers should use the PortletURL objects (or their accompanying tag
libraries) instead of directly manipulating HTTP query strings. The corollary to this
is that developers should not use
GET in HTML forms. This is because portals may
encode internal state parameters in the
PortletURL.
15
The Java Portlet API (JSR 168)
04 469513 Ch01.qxd 1/16/04 11:04 AM Page 15