The portlets probably need access to portal state, such as current navigation, site type and name, page name. GateIn introduces the Portal Navigational Properties feature that provides, in brief:
A way to expose the properties. The exposed properties are configurable, have scope and qualified identifiers.
Access to the properties from the portlets. The portlets can access the properties in the same way as JSR-286 public render parameters.
You can read its specification here.
In eXo Platform package, the ContextualPropertyManager service is configured as follows:
<component>
<key>org.exoplatform.portal.application.state.ContextualPropertyManager</key>
<type>org.exoplatform.portal.application.state.ContextualPropertyManagerImpl</type>
<component-plugins>
<component-plugin>
<name>PublicPropertiesPlugin</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.portal.application.state.PublicPropertiesPlugin</type>
<init-params>
<value-param>
<name>namespaceURI</name>
<description>Namespace URI</description>
<value>http://www.gatein.org/xml/ns/prp_1_0</value>
</value-param>
</init-params>
</component-plugin>
</component-plugins>
</component>
See the source code of ContextualPropertyManager and its plugins here.
The built-in properties are exposed by PublicPropertiesPlugin:
this.navigationURIQName = new QName(namespaceURI, "navigation_uri");
this.pageNameQName = new QName(namespaceURI, "page_name");
this.siteTypeQName = new QName(namespaceURI, "site_type");
this.siteNameQName = new QName(namespaceURI, "site_name");
this.windowWidth = new QName(namespaceURI, "window_width");
this.windowHeight = new QName(namespaceURI, "window_height");
this.windowShowInfoBarQName = new QName(namespaceURI, "window_show_info_bar");
Portlet configuration
To be able to access a property, site_name for example, you need to configure your portlet.xml
:
<portlet-app ...>
<portlet>
...
<supported-public-render-parameter>site_name</supported-public-render-parameter>
</portlet>
<public-render-parameter>
<identifier>site_name</identifier>
<qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:site_name</qname>
</public-render-parameter>
</portlet-app>
ContextualPropertyManager Plugin
You can write a new plugin to add a property, by extending AbstractContextualPropertyProviderPlugin
and overriding getProperties
method (see the code of PublicPropertiesPlugin - linked above).
The plugin should be configured in an extension or in jar!/conf/portal/configuration.xml
like below:
<configuration>
<external-component-plugins>
<target-component>org.exoplatform.portal.application.state.ContextualPropertyManager</target-component>
<component-plugin>
<name>CPPlugin</name>
<set-method>addPlugin</set-method>
<type>com.acme.samples.CPPlugin</type>
<init-params>
<value-param>
<name>namespaceURI</name>
<description>Namespace URI</description>
<value>http://www.gatein.org/xml/ns/prp_1_0</value>
</value-param>
</init-params>
</component-plugin>
</external-component-plugins>
</configuration>
See an example of the plugin and consuming portlet in Developer guide.