Miscellaneous objects

 

+

Search Tips   |   Advanced Search

 

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...

The most important information related to the PortletContext includes...

InitParameters Parameters are name/value pairs available to all portlets within the Web application. These are defined in the Web deployment descriptor under the element...

<context-param>

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.

Here is an example from the web.xml of an AJAX Faces portlet...

 <context-param>
  <description> Value, in milliseconds, to be used for Expires header</description>
  <param-name>com.ibm.faces.RESOURCE_EXPIRE_MS</param-name>
  <param-value>31536000000</param-value>
 </context-param>
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()
  • getResourceAsStream()

The include() method is typically used to invoke JSPs for output. For example...

PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(getJspFilePath(request, VIEW_JSP));

rd.include(request, response);

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.

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 interface represents the users of the portal and provides methods for accessing a subset of the attributes that make up the user profile, such as the user's full name or the user name. The User interface abstracts the underlying physical implementation of the one or more data stores which actually hold the user information.

The getUser() method is located at the PortletRequest and PortletSession. The PortletSession.getUser() method is deprecated and only returns null.

The PUMA SPI includes the User and Group interfaces, which include methods that provide fuller access to the attributes of these objects in the user subsystem of Member Services.

 

Related information

 

Parent topic

IBM Portlet API