Total Pageviews

Saturday, May 30, 2015

Liferay: IPC via Events

IPC (Inter Portlet Communication) in Liferay can be implemented in different ways and  I've already written an article on Public render parameter mechanism. In this article, we'll see Event based IPC. As Public Render Parameters, this concept was also introduced in JSR 286.

As per IPC using Events, portlet can publish/send and process/receive the event. This mechanism works flawlessly with inter and intra WARs.

1. Event deceleration in Event Publisher Portlet's portlet.xml
Full portlet.xml will look like as follows:

2. Event definition in Event Receiver Portlet's portlet.xml
Full portlet.xml will look like as follows:
3. Event Publishing Portlet's Controller Class

Invoking Publish Event method

4. Event Processing Portlet's Controller Class and fethching parameter's value
Note: 'QName' is a nothing but a qualified name of the parameter. Usage of QName minimizes chances of having two identical events.

Liferay: IPC using Public Render Parameters

IPC (Inter Portlet Communication) in Liferay can be implemented in different ways and  we'll see one among the possibilities, i.e. Public Render Parameter. This concept was introduced in JSR 286.

The central idea of this concept is to share a normal parameter across all deployed portlets despite of the fact that they lie in same WAR or in different.

1. In portlet.xml in the end of </portlet> tag we have to define the name of parameter

2. In portlet.xml in the end of <portlet-app> tag we have to define the identifier with the name of parameter

Full portlet.xml file will look like as follows:

Setting Parameter:

Reading Parameter:

Note: If render parameters need to be shared among two different WARs, and you have to set parameter in portlet 1 and read in portlet 2, For achieving this, we have to add definition of render parameter in the portlet.xml file of both the WARs. 

Saturday, October 11, 2014

Liferay: Instance Specific '' File

To start with this topic, we need to refresh the following:
Everybody who works with Liferay, know about file. Just to refresh, this file contains key-value pairs of settings and is present in the classpath to override the properties of file (can be seen in Liferay source code or portal-impl.jar).

Liferay Portal Instance
Liferay Portal allows you to run more than one portal instance on a single server (e.g. tomcat instance). The Portal Instances page of the control panel lets you manage these instances. All portal data, however, is kept in the same database. (You can read in details here)

As a standard practice, the settings we do in file are shared among all portal instances. But with the settings we are now going to discuss will allow us to create different property files for each portal instance, and this is out of box only. To do so, we have to do the following two settings:

1. There are two ways of doing this, first you can set the following property in your file

or you can set this in your setenv.bat or as per your environment. You can enter the above entry just after '-Duser.timezone=IST' in the file.

2. Now we have to create properties file with the naming format 'portal-<<WebId>>.properties'. For instance, if the web id of the instance is 'finance', then the name of the property file for this instance will be

Similarly we can create different property files for other portal instances. The default web id of liferay instance is 'liferay', so the name of property file for this instance will be ''.

Important things to note here is - not all properties can be overridden by this setting. Properties such as database configurations should be in the property file of default instance only.

For testing this, you can try to modify the authentication method. Change the value to screen name in the second instance's properties file while keeping the email (as default come bundled), you will get the second instance authenticating with screen name while the first with email address. It also works well while fetching the values using PropsUtil API.