Miscellaneous objects
The following objects are used by portlets:
PortletContext
The PortletContext interface defines a portlet's view of the portlet container within which each portlet is running. PortletContext also allows a portlet to access resources available to it. For example, using the context, a portlet can access the portlet log, access context parameters common to all portlets within the portlet application, obtain URL references to resources or access portlet services .
The most important information related to the PortletContext is described in detail below.
- InitParameters
- Parameters are name/value pairs available to all portlets within the Web application. These are defined in the Web deployment descriptor under the <context-param> element. For example, if a group of portlets share a context parameter called "Webmaster" that contains the portal site's administrator email, each portlet could get that value and provide a "mailto" link in their help.
- Attributes
- Attributes are name/value pairs available to all portlets within the Web application. The portlet can get, set and remove attributes. Attributes of the context are stored on a single machine and are not distributed in a cluster.
- Localized text
- The getText() method is used by the portlet to access resource bundles within a given locale.
- Resources
- It is through the PortletContext that a portlet can load or include resources located in the portlet's application scope. Available methods are include() and getResourceAsStream(). The include() method is typically used to invoke JSPs for output.
- Messaging
- Through messaging it is possible to communicate between portlets and share data or send notifications. A message is sent by using the send() method. For more information, see Portlet messaging
- Portlet services
- The PortletService object allows portlets to use pluggable services via dynamic discovery.
- Log
- The PortletLog object provides the portlet with the ability to log informational, warning, or error messages. The log is maintained by the portlet container. Whether logging is enabled or not is at the discretion of the portlet container. For more information, see Message and trace logging .
This object is also available from the getPortletLog() method from the PortletAdapter class.
PortletWindow
The PortletWindow object represents the window that encloses a portlet. For example, on an HTML page, the portlet window can typically be rendered as a table cell. The portlet window can send events on manipulation of its various window controls, like when the user clicks minimize or close. The portlet, in turn, can interrogate the window about its current state. For example, a portlet can render its content differently depending on whether its window is maximized or not. The PortletWindow is available using the getWindow() method of the PortletRequest object.
User
The User class represents the users of the portal. The User class contains methods for accessing attributes that make up the user profile, such as the user's full name or the user name. The User class abstracts the underlying physical implementation of the one or more data stores which actually hold the user information.
In WebSphere Portal, the User class is part of the
com.ibm.wps.puma
package. This class and several others represent the portal server's API to the user subsystem in Member Services. To obtain the Javadoc for this API, locate the document titled "Javadoc for the WebSphere Portal User and Group objects" on the software support site, http://www.ibm.com/software/support.The classes in the com.ibm.wps.puma package provide the only API available to access attributes of the user. In subsequent releases of WebSphere Portal, a new API will become available to access the new features of the user subsystem. In that timeframe, the com.ibm.wps.puma package will be maintained for a time for backward compatibility, but will no longer be enhanced to accomodate new function.
Note: The getUser() method is located at the PortletRequest and
PortletSession
. The PortletSession.getUser() method is deprecated and only returns null.
See also