Sun Java System Portal Server 7.2 Developer's Guide

Portlet Policy

Portlet Container 2.0 introduces a Portlet Policy that governs policies related to events, container events and public render parameters. The policy specifies how the events, container events, and public render parameters are distributed. It also specifies the maximum generation of events to prevent endless loops. If a portlet sends an event to other portlets, it is considered as one event generation. If the other portlets send events, that is considered as two event generations and so on. It also provides the ability to enable/disable the container events.

The portlet-policy.xml file is located in PortalServer-Data-Directory/portals/portal-id/config. The schema is located at https://portlet-container.dev.java.net/xml/portlet-policy.xsd.

The portlet-policy.xml file looks like this:


<portlet-policy
	xmlns="https://portlet-container.dev.java.net/xml/portlet-policy.xsd"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="https://portlet-container.dev.java.net/xml/portlet-policy.xsd"
	version="1.0">

<event-policy>
	<event-distribution>VISIBLE_PORTLETS_ON_PAGE</event-distribution>
	<max-event-generation>3</max-event-generation>
</event-policy>

<container-event-policy>
	<event-distribution>ALL_PORTLETS</event-distribution>
	<max-event-generation>2</max-event-generation>
	<event>
		<name>login</name>
		<status>enabled</status>
	</event>
	<event>
		<name>logout</name>
		<status>enabled</status>
	</event>
</container-event-policy>

<public-render-parameter-policy>
	<public-render-parameter-distribution>VISIBLE_PORTLETS_ON_PAGE</public-render-parameter-distribution>
</public-render-parameter-policy>

</portlet-policy>

The above example shows that only visible portlets on the page will receive events and public render parameters. This also specifies that the maximum number of events permitted to be generated is two. This also specifies that the container events, login and logout are enabled. Currently, only login and logout container events are supported.

Any portlet interested in login event should specify the following in its portlet.xml. The processEvent() method of the portlet will be called when the user logs in.


<supported-processing-event>
	<qname xmlns:x="urn:oasis:names:tc:wsrp:v2:types">
		x:login
	</qname>
</supported-processing-event>

Any portlet interested in logout event should specify the following in its portlet.xml. The processEvent() method of the portlet will be called when the user logs out.


<supported-processing-event>
	<qname xmlns:x="urn:oasis:names:tc:wsrp:v2:types">
		x:logout
	</qname>
</supported-processing-event>