Listeners


The Portlet API provides listeners, which can add more functionality for a portlet. To enable the listener's functionality, one of the following interfaces must be implemented by the portlet.

 

PortletSessionListener

In addition to the concrete portlet instance, which exists for each portlet occurrence on a page, a portlet may have an even finer granularity. The PortletSessionListener allows a portlet to recognize the life cycle of a user portlet instance:

 

PortletPageListener

A portlet has no control or awareness of the order in which the output from all of the portlets on the page is written. The PortletPageListener allows a portlet to insert markup at the beginning and ending of a page.

These methods are called if the <wps:pageRender/> tag includes the attributes includeBeginPage="yes" and includeEndPage="yes". The <wps:pageRender/> tag can be found in the file Home.jsp in the /screens directory.

 

Listener life cycle

When implementing PortletSesssionListener and PortletPageListener, the following methods are called on the portlet during its life cycle.

 

PortletTitleListener

The PortletTitleListener interface is used to allow the portlet title, as it is displayed in the title bar, to be changed based on a condition (for example, the type of device used to access the portal) or user input (for example, a preference that the user sets on the edit page). If the Listener is not implemented, the portlet displays the title specified on the <title> element (under <language>) of the portlet deployment descriptor.

 

PortletSettingsAttributesListener

This interface listens for changes to the attributes of the PortletSettings, like when an administrator configures a concrete portlet.

 

PortletApplicationSettingsAttributesListener

This interface listens for changes to the attributes of the PortletApplicationSettings, like when an administrator configures a concrete portlet application.

See also