Porlet Preferences In Liferay 7

Portlet preferences is a feature of Liferay to store portlet level configuration data. These data are stored in the database. We can also store Portlet Preferences as key-value pair using portlet.xml file or  PortletPreferences class. In this blog we will discuss about storing portlet preferences.

There are two ways of adding portlet preferences,

i. PortletPreference Interface

ii. Portlet.xml

1. We will use the same liferay project that we created while demonstrating the logger example. i.e. Using logger in Liferay 7

21-1

2. Add the below code in the controller. This code snippet will add a portlet preference “name” with PortletPreference interface on click of ,

@Override
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
_log.info("START... Adding Portlet Preference...");
PortletPreferences preferences = request.getPreferences();
preferences.setValue("name", "RC Blog Portlet Preference Portlet");
preferences.store();
_log.info("DONE... Adding Portlet Preference...");

response.setRenderParameter("jspPage", "/html/bloglogger/view.jsp");
}

21-2

3. Now let’s add another preference using portlet.xml. Add the below snippet in portlet.xml,

<portlet-preferences>
<preference>
<name>description</name>
<value>RC Blog Portlet Preference Portlet Description</value>
</preference>
</portlet-preferences>

21-3

4. We are now done with adding portlet preferences using both PortletPreference and portlet.xml file. Now let’s retrieve those preferences in view.jsp. Add the below code snippet in view.jsp file,

<%@page import="javax.portlet.PortletPreferences"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<portlet:defineObjects />

<portlet:actionURL var="setPreferenceURL"></portlet:actionURL>

This is the <b>Blog Logger</b> portlet in View mode.

<form action="<%=setPreferenceURL%>" method="POST">
<input type="submit" value="Set Preference">
</form>


<%
String name = portletPreferences.getValue("name", "-");
String description = portletPreferences.getValue("description", "-");
%>

PortletPreference Interface Preference name: <%=name%>



Portlet.xml Preference description: <%=description%>

21-4

5. Let’s build and deploy the code. Then click on “Set Preference” button.

21-5

 

Please Note – Two important findings,

  1. Never use “preferences.store();” in a render cycle method e.g. doView. This will throw “java.lang.IllegalStateException – if this method is called inside a render call”. Click here for more details.
  2. As you can see, preference settings using portlet.xml is not working in Liferay 7. But we tested it in Liferay 6.2 and it works. It looks like a bug in Liferay 7 (Liferay Community Edition Portal 7.0.1 GA2 (Wilberforce / Build 7001 / June 10, 2016)).

 

Happy Coding… 🙂
Rupal Chatterjee
Sr. Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

Finder Method – Service Builder in Liferay 7

In our last two blogs, we have discussed on a sample implementation on Liferay service builder(i.e. Service Builder in Liferay 7) and details service.xml file (i.e. Explain service.xml – Service Builder in Liferay 7)

In this blog, we will discuss on Finder method feature provided by Liferay service builder. Finder method is a feature of Liferay service that enables us to create fetch/retrieval methods according to our requirement.

1. We will use the same liferay project that we created while demonstrating the Service Builder example. i.e. Service Builder in Liferay 7

20-1

2. In the existing service.xml, we will create a Finder method by email.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.rc.blog.service">
<author>rupal.chatterjee</author>
<namespace>rcblog</namespace>
<entity name="Customer" local-service="true" table="TBL_CUSTOMER">
<column name="CustomerId" type="long" primary="true" id-type="increment"></column>
<column name="Name" type="String"></column>
<column name="Age" type="int"></column>
<column name="Phone" type="String"></column>
<column name="Email" type="String"></column>

<finder name="EmailId" return-type="Collection">
<finder-column name="Email"></finder-column>
</finder>
</entity>
</service-builder>

3. On successful service build, this will generate a method findByEmailId() in com.rc.blog.service.service.persistence.CustomerUtil class.

20-2

4. To use this method we have expose the finder method to our LocalServiceUtil class. Open “CustomerLocalServiceImpl” class and add the below code in it.

public List<Customer> findByEmailId(java.lang.String Email) {
return getCustomerPersistence().findByEmailId(Email);
}

20-3

5. Now build the services again, this method will be added CustomerLocalServiceUtil.

20-4

6. Add the below code in doView to get the list of all Customers with emailId a@b.com.

_log.info("START... Find Customer...");
List<Customer> customers = CustomerLocalServiceUtil.findByEmailId("a@b.com");
for(Customer customer : customers){
_log.info("Customer found : " + customer.toString());
}
_log.info("DONE... Find Customer...");

20-5

7. Now let’s build and deploy the portlet.

OUTPUT – 

[BlogLoggerPortlet:37] START... Process Customer...
[BlogLoggerPortlet:50] DONE... Process Customer...
[BlogLoggerPortlet:52] START... Find Customer...
[BlogLoggerPortlet:55] Customer found : {CustomerId=1, Name=Rupal Chatterjee, Age=28, Phone=111-11111, Email=a@b.com}
[BlogLoggerPortlet:57] DONE... Find Customer...

20-6

 

Happy Coding… 🙂

Rupal Chatterjee
Sr. Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

 

 

Explaining service.xml – Service Builder in Liferay 7

In our last blog, we have discussed on a sample implementation on Liferay service builder(i.e. Service Builder in Liferay 7). In this particular blog we will discuss only about service.xml file that we created in my previous blog.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.rc.blog.service">
<author>rupal.chatterjee</author>
<namespace>rcblog</namespace>
<entity name="Customer" local-service="true" table="TBL_CUSTOMER">
<column name="CustomerId" type="long" primary="true" id-type="increment"></column>
<column name="Name" type="String"></column>
<column name="Age" type="int"></column>
<column name="Phone" type="String"></column>
<column name="Email" type="String"></column>
</entity>
</service-builder>

Lets move line-by-line and discuss the details,

1. service-builder package-path=”com.rc.blog.service”

Liferay generates all classes in the provided package-path.

2. <author>rupal.chatterjee</author>

This is not a mandatory tag. This tag helps Liferay to generate proper Javadoc.

19-1

3. <namespace>rcblog</namespace>

This is a mandatory tag. This helps to create tables with a specific naming convention.We have another attribute, auto-namespace-tables=”true/false” in “service-builder” tag.

For example,If we have auto-namespace-tables=true set, then liferay will create the tables as “<namespace>_<entity name>”.

But, if we mention the “table” attribute in “entity” tag, then Liferay will ignore the namespace.

i.e. <entity name=”Customer” local-service=”true” table=”TBL_CUSTOMER”>

In this case, Liferay will create the table as “TBL_CUSTOMER” irrespective of the “auto-namespace-tables” property.

19-2

4. <entity name=”Customer” local-service=”true” table=”TBL_CUSTOMER”>

This is a mandatory tag.

i. name=”Customer”

This is a mandatory attribute. Liferay uses the entity name to Generate all java class. For Example – Customer, CustomerLocalServiceUtils etc.

In some case it is also used as the table name as described in the previous point.

ii. local-service=”true”

If we set the values as true, Liferay allows us to use the services as web-services.

iii. table=”TBL_CUSTOMER”

As described in point no. 3, this is not a mandatory tag. Liferay uses the table tag to create the table in database using that name.

5. <column name=”CustomerId” type=”long” primary=”true” id-type=”increment”></column>

This tag defines each column of the table.

i. name=”CustomerId”

This is the name of the column in the database.

ii. type=”long”

This is the datatype of the coumn.

iii. primary=”true”

This specify that the given column is a Primary key.

iv. id-type=”increment”

This specify that the given column is an auto-generated type.

19-3

 

Happy Coding… 🙂
Rupal Chatterjee
Sr. Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

 

Service Builder in Liferay 7

Liferay provides a mechanism to simplify DB connectivity which is called Service Builder. As the name suggest, Liferay helps the developer by creating all CRUD (CREATE-READ-UPDATE-DELETE) functions and classes. The developer just need to provide the table structure in a xml file and rest is taken care by Liferay.

In this example we will go through each phase step by step,

1. We will use the same liferay project that we created while demonstrating the logger example. i.e. Using Logger in Liferay 7

18-1

2. Right click on the “RC-Blog-Logger-Example-portlet”, then click on “New à Liferay Service Builder”.

18-2

3. Fill the details and click “Finish”. This will create a service.xml file inside WEB-INF folder.

18-3

18-4

4. Open the service.xml file in “Overview” mode. Remove the auto generated entity “Foo” and add a new Entity “Customer”.

18-5

5. Then click on “Customer” entity and provide the table name “TBL_CUSTOMER”.

18-6

6. Now click on “Columns” and define the required columns.

18-7

7. Now as a normal practice we want the primary key to be auto-generated. Select “CustomerId” and change the “Id Type” to “increment”.

18-8

8. Now we are done with the table structure creation. The service.xml now looks like this,

18-9

9. Now open the “Service.xml” file in “Overview” mode and click on “Build Services”.

18-10

10. On successful service build, all service related class will be generated inside “src”.

18-11

11. Add the below code snippet in “doView” method,

_log.info("START... Process Customer...");
try {
long cid = CounterLocalServiceUtil.increment(Customer.class.getName());
Customer customer = new CustomerImpl();
customer.setCustomerId(cid);
customer.setName("Rupal Chatterjee");
customer.setPhone("111-11111");
customer.setAge(28);
customer.setEmail("a@b.com");
CustomerLocalServiceUtil.addCustomer(customer);
} catch (SystemException e) {
_log.error(e);
}
_log.info("DONE... Process Customer...");

18-12

12. Build and Deploy the code.

13. Once the portlet is executed, go ahead and check the liferay database. A new table TBL_CUSTOMER should be added along with the sample data we created.

18-1318-14

Happy Coding… 🙂
Rupal Chatterjee
Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

Browse HSQL / Hypersonic Database in Liferay using Eclipse

While working on Liferay and HSQL that comes in the liferay bundle, we must have thought “how to browse those HSQL tables in a database editor”.

This is highly important especially when you are exploring Service Builder functionality. To check the real existence of those table you just created using Service Builder is real-time necessity.

In this example we will try to establish a connection to our HSQL database using Eclipse.

1. Open Eclipse and navigate to Window –> Show View –> Data Source Explorer

17-1

2. Right Click on “Database Connections –> New…”.

17-2

3. In the “New Connection Profile” window, search with “hsql” and select “HSQLDB”. Provide a proper name for the connection e.g. Liferay 7 HSQLDB.

17-3

4. Click next and navigate to Driver selection screen.

17-4

5. Click on the icon right to the driver selection dropdown saying “New Driver Definition”. And select “HSQLDB JDBC Driver”.

17-5

6. Then move to the next tab i.e. “Jar List”. Click on “Edit Jar/Zip” and point it to Liferay hsql.jar.

Location: <Liferay_HOME>\tomcat-8.0.32\lib\ext\hsql.jar

17-617-717-817-9

7. Enter all the database credentials and Click on “Test Connection”.

Database Location: <LIFERAY_HOME> /data/hsql/lportal

OR

<LIFERAY_HOME> /data/hypersonic/lportal (Default for Liferay 7)

Username: sa

17-1017-11

8. Click “Next >” to view the connection details. Then click “Finish”.

17-12

9. Now all the liferay tables should be visible under “PUBLIC”.

17-13

 

Happy Coding… 🙂
Rupal Chatterjee
Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

Inter Portlet Communication (IPC) – Client Side in Liferay 7

Inter portlet communication is a mechanism to communicate between the portlets. This is a new feature brought up in JSR 286 (Java Specification Request). This mode of IPC uses javascript to communicate. Hence it is only applicable for portlets residing in the same page. Its uses liferay javascript library to trigger and receive events.

Let’s move step by step,

1. Create a new Liferay Plugin Project. Name it as “RC-Blog-IPC-Example”.

16-1

2. Now create two portlets “IPCSender” and “IPCReceiver”.

16-216-3

3. In liferay-portlet.xml file, for “IPC-Sender” portlet add the below few lines,

<requires-namespaced-parameters>false</requires-namespaced-parameters>

16-4

4. In view.jsp for “IPC Sender”, copy the below code,

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<portlet:actionURL name="nameAction" var="actionUrl"></portlet:actionURL>

<form action="<%=actionUrl%>" method="POST">
What's your name: <input type="text" name="name" id="eventUserName">

<input type="button" id="submitBtn" name="Submit" value="Submit">
</form>

<script type="text/javascript">
$(document).ready(function() {
 $("#submitBtn").click(function() {
 var name = $("#eventUserName").val();
 Liferay.fire('userNameEvent', {
 userName : name
 });
 });
});
</script>

16-5

5. Till now we are done with the Sender class of the IPC. Now we need to work of the Receiver class, which will receive the “username” attribute from portlet session and process accordingly.

6. In the view.jsp for “IPC Receiver” portlet, paste the below code,

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />
<h3>IPC User Name: <span id="eventUserNameLabel">${userName}</span></h3>
<script type="text/javascript">
$(document).ready(function() {
 Liferay.on( 'userNameEvent',
 function(event) {
 var userName = event.userName;
 $('#eventUserNameLabel').html(userName);
 });
});
</script>

16-6

7. Now let build and deploy the portlet. Add both “IPC Sender” and “IPC Receiver” portlet in a page.

16-716-8

8. Now fill the textfield inside “IPC Sender” portlet and hit “Submit”.

16-9

The name entered in the “IPC Sender” portlet is now visible in “IPC Receiver” portlet.

 

Happy Coding… 🙂
Rupal Chatterjee
Sr. Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

Inter Portlet Communication (IPC) – Events in Liferay 7

Inter portlet communication is a mechanism to communicate between the portlets. This is a new feature brought up in JSR 286 (Java Specification Request). This mode of IPC is done using Producer and Listener model.

Let’s move step by step,

1. Create a new Liferay Plugin Project. Name it as “RC-Blog-IPC-Example”.

15-1

2. Now create two portlets “IPCSender” and “IPCReceiver”

15-215-3

3. In liferay-portlet.xml file, for “IPC-Sender” portlet add the below few lines,

<requires-namespaced-parameters>false</requires-namespaced-parameters>

15-4

4. In portlet.xml for both “IPC Sender” and “IPC Receiver” add the below entires,

i. Sender –

<supported-publishing-event>
<qname xmlns:x="http://rcblog.com/variables">x:userName</qname>
</supported-publishing-event>

15-5

ii. Receiver –

<supported-processing-event>
<qname xmlns:x="http://rcblog.com/variables">x:userName</qname>
</supported-processing-event>

15-6

5. In view.jsp for “IPC Sender”, copy the below code,

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<portlet:actionURL name="nameAction" var="actionUrl"></portlet:actionURL>

<form action="<%=actionUrl%>" method="POST">
What's your name: <input type="text" name="name">

<input type="submit" name="Submit" value="Submit">
</form>

15-7

6. In the “IPCSender” controller class, add the below code snippet,

@ProcessAction(name = "nameAction")
public void nameAction(ActionRequest request, ActionResponse response) {
String name = ParamUtil.getString(request, "name", StringPool.BLANK);
_log.info("IPC Sender name: " + name);

QName userNameEvent = new QName("http://rcblog.com/variables", "userName");
response.setEvent(userNameEvent, name);
}

15-8

7. Till now we are done with the Sender class of the IPC. Now we need to work of the Receiver class, which will receive the “username” attribute from portlet session and process accordingly.

8. In the “IPCReceiver” controller class, add a new method as shown in the below snippet,

@ProcessEvent(qname = "{http://rcblog.com/variables}userName")
public void receiveUserName(EventRequest request, EventResponse response) {
Event event = request.getEvent();
String userName = (String) event.getValue();

_log.info("IPC Receiver name: " + userName);

request.setAttribute("userName", userName);
}

15-9

9. In the view.jsp for “IPC Receiver” portlet, paste the below code,

15-10

10. Now let build and deploy the portlet. Add both “IPC Sender” and “IPC Receiver” portlet in a page.

15-1115-12

11. Now fill the textfield inside “IPC Sender” portlet and hit “Submit”.

15-13

The name entered in the “IPC Sender” portlet is now visible in “IPC Receiver” portlet.

 

Happy Coding… 🙂
Rupal Chatterjee
Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

Inter Portlet Communication (IPC) – Public Render Parameter in Liferay 7

Inter portlet communication is a mechanism to communicate between the portlets. This is a new feature brought up in JSR 286 (Java Specification Request). This mode of IPC works on the shared render parameters amongst multiple portlets.

Let’s move step by step,

1. Create a new Liferay Plugin Project. Name it as “RC-Blog-IPC-Example”.

14-1

2. Now create two portlets “IPCSender” and “IPCReceiver”.

14-214-3

3. In liferay-portlet.xml file, for “IPC-Sender” portlet add the below few lines,

<requires-namespaced-parameters>false</requires-namespaced-parameters>

14-4

4. In portlet.xml for both “IPC Sender” and “IPC Receiver” add the below entires,

<supported-public-render-parameter>userName</supported-public-render-parameter>
<public-render-parameter>
<identifier>userName</identifier>
<qname xmlns:x="http://rcblog.com/variables">x:userName</qname>
</public-render-parameter>

14-5

5. In view.jsp for “IPC Sender”, copy the below code,

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<portlet:actionURL name="nameAction" var="actionUrl"></portlet:actionURL>

<form action="<%=actionUrl%>" method="POST">
What's your name: <input type="text" name="name">

<input type="submit" name="Submit" value="Submit">
</form>

14-6

6. In the “IPCSender” controller class, add the below code snippet,

@ProcessAction(name = "nameAction")
public void nameAction(ActionRequest request, ActionResponse response) {
String name = ParamUtil.getString(request, "name", StringPool.BLANK);
_log.info("IPC Sender name: " + name);
response.setRenderParameter("username", name);
}

14-7

7. Till now we are done with the Sender class of the IPC. Now we need to work of the Receiver class, which will receive the “username” attribute from portlet session and process accordingly.

8. In the “IPCReceiver” controller class, replace the “doView” method with the below code,

public void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
String userName = renderRequest.getParameter("username");
if (userName != null) {
renderRequest.setAttribute("userName", userName);
}

include(viewTemplate, renderRequest, renderResponse);
}

14-8

9. In the view.jsp for “IPC Receiver” portlet, paste the below code,

14-9

10. Now let build and deploy the portlet. Add both “IPC Sender” and “IPC Receiver” portlet in a page.

14-1014-11

11. Now fill the textfield inside “IPC Sender” portlet and hit “Submit”.

14-12

The name entered in the “IPC Sender” portlet is now visible in “IPC Receiver” portlet.

 

Happy Coding… 🙂
Rupal Chatterjee
Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

Inter Portlet Communication (IPC) – Portlet Session in Liferay 7

Inter portlet communication is a mechanism to communicate between the portlets. This is a new feature brought up in JSR 286 (Java Specification Request). Communication between two portlets can a done using Portlet Session. Using this way, two different portlets in different pages can also communicate.

Let’s move step by step,

1. Create a new Liferay Plugin Project. Name it as “RC-Blog-IPC-Example”.

13-1

2. Now create two portlets “IPCSender” and “IPCReceiver”.

13-213-3

3. In liferay-portlet.xml file, for “IPC-Sender” portlet add the below few lines,

<private-session-attributes>false</private-session-attributes>
<requires-namespaced-parameters>false</requires-namespaced-parameters>

13-4

4. In view.jsp for “IPC Sender”, copy the below code,

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<portlet:actionURL name="nameAction" var="actionUrl"></portlet:actionURL>

<form action="<%=actionUrl%>" method="POST">
What's your name: <input type="text" name="name">

<input type="submit" name="Submit" value="Submit">
</form>

13-5

5. In the “IPCSender” controller class, add the below code snippet,

@ProcessAction(name = "nameAction")
public void nameAction(ActionRequest request, ActionResponse response) {
 String name = ParamUtil.getString(request, "name", StringPool.BLANK);
 _log.info("IPC Sender name: " + name);

 PortletSession session = request.getPortletSession();
 session.setAttribute("username", name, PortletSession.APPLICATION_SCOPE); 
}

13-6

6. Till now we are done with the Sender class of the IPC. Now we need to work of the Receiver class, which will receive the “username” attribute from portlet session and process accordingly.

7. In the “IPCReceiver” controller class, replace the “doView” method with the below code,

public void doView(
 RenderRequest renderRequest, RenderResponse renderResponse)
 throws IOException, PortletException {

 PortletSession session = renderRequest.getPortletSession();
 String userName = (String) session.getAttribute("username", PortletSession.APPLICATION_SCOPE);
 if (userName != null) {
 renderRequest.setAttribute("userName", userName);
 }

 include(viewTemplate, renderRequest, renderResponse);
}

13-7

8. In the view.jsp for “IPC Receiver” portlet, paste the below code,

13-8

9. Now let build and deploy the portlet. Add both “IPC Sender” and “IPC Receiver” portlet in a page.

13-913-10

10. Now fill the textfield inside “IPC Sender” portlet and hit “Submit”.

13-11

The name entered in the “IPC Sender” portlet is now visible in “IPC Receiver” portlet.

 

Happy Coding… 🙂
Rupal Chatterjee
Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook

Inter Portlet Communication (IPC) in Liferay 7

Inter portlet communication is a mechanism to communicate between the portlets. This is a new feature brought up in JSR 286 (Java Specification Request). There are four different ways of IPC, let’s discuss each one of them one by one,

1. Portlet Session IPC –

Communication between two portlets can a done using Portlet Session. Using this way, two different portlets in different pages can also communicate.

For example –

i. Sender –

PortletSession session = request.getPortletSession();
session.setAttribute("<session-variable-name>","<session-variable-value>", PortletSession.APPLICATION_SCOPE);

ii. Receiver –

PortletSession session = renderRequest.getPortletSession();
String value = (String) session.getAttribute("<session-variable-name>", PortletSession.APPLICATION_SCOPE);

2. Public Render Parameter IPC –

This mode of IPC works on the shared render parameters among multiple portlets. By default this IPC works on portlets available on single page. But using the below property in portal-ext.properties file allow us to use shared render parameters across all pages.

portlet.public.render.parameter.distribution=layout-set

For both Sender and Receiver,

<supported-public-render-parameter>testRenderParam</supported-public-render-parameter>

<public-render-parameter>
<identifier>testRenderParam</identifier>
<qname xmlns:x="http://rcblog.com/public">x:testRenderParam</qname>
</public-render-parameter>

3. Event IPC –

This mode of IPC is done using Producer and Listener model. By default this mode of IPC works on portlets available on single page. But using the below property in portal-ext.properties file allow us to use shared render parameters across all pages.

portlet.event.distribution=layout-set

i. Event Producer –

<supported-publishing-event xmlns:event="http://www.rcblog.com">
<qname>event:testParam</qname>
</supported-publishing-event>

ii. Event Listener –

<supported-processing-event xmlns:event="http://www.rcblog.com">
<qname>event:testParam</qname>
</supported-processing-event>

4. Client Side IPC –

This mode of IPC uses javascript to communicate. Hence it is only applicable for portlets residing in the same page. Its uses liferay javascript library to trigger and receive events.

i. Sender –

Liferay.fire('rcblogEvent',{
	testParam: Lorem Ipsum
});

ii. Receiver –

Liferay.on('rcblogEvent',function(event) {
console.log('Test Param Value:'+ event.testParam);
});

 
Happy Coding… 🙂
Rupal Chatterjee
Associate Projects, Cognizant Technology Solutions
https://www.cognizant.com
Connect me on Google, Facebook