SlideShare a Scribd company logo
1 of 6
Create IPC Portlet in Liferay 6.1.1 ga2
The first version of the portlet specification, JSR-168/portlet1.0, did not include any
support for Inter Portlet Communication. The second version, JSR-286/ portlet2.0,
which is supported for IPC Mechanism.
IPC is made easy with JSR-286 to share the data between two portlets. Using IPC
mechanisms, we can share the data from ACTION to VIEW phase and VIEW-VIEW
Phase.
Public Render Parameter: IPC (Inter Portlet Communication):
In JSR 168, the render parameters set in processAction is only available in the render of the
same portlet. With the Public Render Parameters feature, the render parameters set in the
processAction of one portlet will be available in render of other portlets also.
By adding the following property in portlet-ext, we can enable portlets to share render
states with other portlets that are on different pages:
portlet.public.render.parameter.distribution=ALL_PORTLETS
Follow Steps to create IPC Portlet in Liferay 6.1.1 ga2
Step 1: Create new demoipc-portlet
Give first portlet name:sender
Step 2: Create second portlet in same project
Give portlet name:receiver
Step 3: In package com.test make two java class file
Sender.java
package com.test;
import java.io.IOException;
import java.util.Random;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.ProcessAction;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.xml.namespace.QName;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class sender
*/
public class sender extends MVCPortlet {
@ProcessAction(name="pitchBall")
public void pitchBall(ActionRequest request, ActionResponse response) {
String pitchType = null;
System.out.println("pitch call");
// Send an Event that the ball has been pitched.
Random random = new Random(System.currentTimeMillis());
int pitch = random.nextInt(3) + 1;
switch (pitch) {
case 1:
pitchType = "Fast Ball";
break;
case 2:
pitchType = "Curve Ball";
break;
case 3:
pitchType = "Slider";
break;
// should never print
default:
pitchType = "Screw Ball";
}
pitchType=pitchType+"Hai You have received Event Data sent from Sender Portlet";
javax.xml.namespace.QName qName =
new QName("http://liferay.com", "ipc.pitch", "x");
response.setEvent(
qName,
pitchType);
System.out.println("call here");
}
}
Receiver.java
package com.test;
import javax.portlet.Event;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
import javax.portlet.ProcessEvent;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class receiver
*/
public class receiver extends MVCPortlet {
@javax.portlet.ProcessEvent(qname = "{http://liferay.com}ipc.pitch")
public void handleProcessempinfoEvent(
javax.portlet.EventRequest request, javax.portlet.EventResponse
response)
throws javax.portlet.PortletException, java.io.IOException {
javax.portlet.Event event = request.getEvent();
String value = (String) event.getValue();
System.out.print("value in process event>>>>>>>>>" + value);
response.setRenderParameter("ipc.pitch", value);
}
}
Step 4: Edit the portlet.xml
-Add below attribute in “Sender-Portlet”
-Before closing of </portlet>
<supported-processing-event xmlns:x='http://liferay.com'>
<qname>x:ipc.pitch</qname>
</supported-processing-event>
</portlet>
<event-definition xmlns:x='http://liferay.com'>
<qname>x:ipc.pitch</qname>
<value-type>java.lang.String</value-type>
</event-definition>
</portlet-app>
Note: We can declare a list of public paramters for a portlet application.
-Add below attribute in “recevier-Portlet”
-Before closing of </portlet>
<supported-processing-event xmlns:x='http://liferay.com'>
<qname>x:ipc.pitch</qname>
</supported-processing-event>
</portlet>
<event-definition xmlns:x='http://liferay.com'>
<qname>x:ipc.pitch</qname>
<value-type>java.lang.String</value-type>
</event-definition>
</portlet-app>
In my example I have created both portlet in same project so here I have add
both changes in same portlet.xml file
Portlet.xml
<?xml version="1.0"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
<portlet>
<portlet-name>sender</portlet-name>
<display-name>sender</display-name>
<portlet-class>com.test.sender</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/html/sender/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>sender</title>
<short-title>sender</short-title>
<keywords></keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
<supported-processing-event xmlns:x='http://liferay.com'>
<qname>x:ipc.pitch</qname>
</supported-processing-event>
</portlet>
<portlet>
<portlet-name>receiver</portlet-name>
<display-name>receiver</display-name>
<portlet-class>com.test.receiver</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/html/receiver/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>receiver</title>
<short-title>receiver</short-title>
<keywords></keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
<supported-processing-event xmlns:x='http://liferay.com'>
<qname>x:ipc.pitch</qname>
</supported-processing-event>
</portlet>
<event-definition xmlns:x='http://liferay.com'>
<qname>x:ipc.pitch</qname>
<value-type>java.lang.String</value-type>
</event-definition>
</portlet-app>
Step 5: A portlet can read public render parameter using following
method
request.getPublicParameterMap()
Note: Public render parameters are merged with regular parameters so can also be
read using
request.getParameter(“id1”);
Step 6: A portlet can remove a public render parameter by invoking
following methods
response.removePublicRenderParameter(“id1”)
Step 7: Make view.jsp for sender and receiver
Make view.jsp in html/sender/view.jsp
View.jsp
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects />
vbjhbnj
<p>Click the link below to pitch the ball. </p>
<a href="<portlet:actionURL name="pitchBall"></portlet:actionURL>">Pitch!</a>
Make view.jsp in html/recevier/view.jsp
View.jsp
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects />
<%
String pitch = (String)renderRequest.getParameter("ipc.pitch");
%>
<p>And the pitch is....</p>
<p>
<% if (pitch!=null) { %>
<%=pitch %>!
<% } else { %>
... waiting for pitch.
<% } %>
Step 8: now deploy it and check it
Liferay development is not at all an simpley task as it requires a expetise with vast
experience. Attune Infocom is one of the fastest growing Liferay development firms,
which has an extremely talented pool of liferay developers who can develop custom
liferay portals for you. Attuene Infocom offer outsource Liferay Portal development
solution at worldwide.

More Related Content

Recently uploaded

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Featured

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Create IPC Portlet in Liferay 6.1.1 ga2

  • 1. Create IPC Portlet in Liferay 6.1.1 ga2 The first version of the portlet specification, JSR-168/portlet1.0, did not include any support for Inter Portlet Communication. The second version, JSR-286/ portlet2.0, which is supported for IPC Mechanism. IPC is made easy with JSR-286 to share the data between two portlets. Using IPC mechanisms, we can share the data from ACTION to VIEW phase and VIEW-VIEW Phase. Public Render Parameter: IPC (Inter Portlet Communication): In JSR 168, the render parameters set in processAction is only available in the render of the same portlet. With the Public Render Parameters feature, the render parameters set in the processAction of one portlet will be available in render of other portlets also. By adding the following property in portlet-ext, we can enable portlets to share render states with other portlets that are on different pages: portlet.public.render.parameter.distribution=ALL_PORTLETS Follow Steps to create IPC Portlet in Liferay 6.1.1 ga2 Step 1: Create new demoipc-portlet Give first portlet name:sender Step 2: Create second portlet in same project Give portlet name:receiver Step 3: In package com.test make two java class file Sender.java
  • 2. package com.test; import java.io.IOException; import java.util.Random; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.PortletException; import javax.portlet.PortletRequestDispatcher; import javax.portlet.ProcessAction; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.xml.namespace.QName; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.util.bridges.mvc.MVCPortlet; /** * Portlet implementation class sender */ public class sender extends MVCPortlet { @ProcessAction(name="pitchBall") public void pitchBall(ActionRequest request, ActionResponse response) { String pitchType = null; System.out.println("pitch call"); // Send an Event that the ball has been pitched. Random random = new Random(System.currentTimeMillis()); int pitch = random.nextInt(3) + 1; switch (pitch) { case 1: pitchType = "Fast Ball"; break; case 2: pitchType = "Curve Ball"; break; case 3: pitchType = "Slider"; break; // should never print default: pitchType = "Screw Ball"; } pitchType=pitchType+"Hai You have received Event Data sent from Sender Portlet"; javax.xml.namespace.QName qName = new QName("http://liferay.com", "ipc.pitch", "x"); response.setEvent( qName, pitchType); System.out.println("call here");
  • 3. } } Receiver.java package com.test; import javax.portlet.Event; import javax.portlet.EventRequest; import javax.portlet.EventResponse; import javax.portlet.ProcessEvent; import com.liferay.util.bridges.mvc.MVCPortlet; /** * Portlet implementation class receiver */ public class receiver extends MVCPortlet { @javax.portlet.ProcessEvent(qname = "{http://liferay.com}ipc.pitch") public void handleProcessempinfoEvent( javax.portlet.EventRequest request, javax.portlet.EventResponse response) throws javax.portlet.PortletException, java.io.IOException { javax.portlet.Event event = request.getEvent(); String value = (String) event.getValue(); System.out.print("value in process event>>>>>>>>>" + value); response.setRenderParameter("ipc.pitch", value); } } Step 4: Edit the portlet.xml -Add below attribute in “Sender-Portlet” -Before closing of </portlet> <supported-processing-event xmlns:x='http://liferay.com'> <qname>x:ipc.pitch</qname> </supported-processing-event> </portlet> <event-definition xmlns:x='http://liferay.com'> <qname>x:ipc.pitch</qname> <value-type>java.lang.String</value-type> </event-definition> </portlet-app> Note: We can declare a list of public paramters for a portlet application. -Add below attribute in “recevier-Portlet”
  • 4. -Before closing of </portlet> <supported-processing-event xmlns:x='http://liferay.com'> <qname>x:ipc.pitch</qname> </supported-processing-event> </portlet> <event-definition xmlns:x='http://liferay.com'> <qname>x:ipc.pitch</qname> <value-type>java.lang.String</value-type> </event-definition> </portlet-app> In my example I have created both portlet in same project so here I have add both changes in same portlet.xml file Portlet.xml <?xml version="1.0"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0"> <portlet> <portlet-name>sender</portlet-name> <display-name>sender</display-name> <portlet-class>com.test.sender</portlet-class> <init-param> <name>view-jsp</name> <value>/html/sender/view.jsp</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> <portlet-info> <title>sender</title> <short-title>sender</short-title> <keywords></keywords> </portlet-info> <security-role-ref> <role-name>administrator</role-name> </security-role-ref> <security-role-ref> <role-name>guest</role-name> </security-role-ref> <security-role-ref>
  • 5. <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</role-name> </security-role-ref> <supported-processing-event xmlns:x='http://liferay.com'> <qname>x:ipc.pitch</qname> </supported-processing-event> </portlet> <portlet> <portlet-name>receiver</portlet-name> <display-name>receiver</display-name> <portlet-class>com.test.receiver</portlet-class> <init-param> <name>view-jsp</name> <value>/html/receiver/view.jsp</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> <portlet-info> <title>receiver</title> <short-title>receiver</short-title> <keywords></keywords> </portlet-info> <security-role-ref> <role-name>administrator</role-name> </security-role-ref> <security-role-ref> <role-name>guest</role-name> </security-role-ref> <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</role-name> </security-role-ref> <supported-processing-event xmlns:x='http://liferay.com'> <qname>x:ipc.pitch</qname> </supported-processing-event> </portlet> <event-definition xmlns:x='http://liferay.com'> <qname>x:ipc.pitch</qname> <value-type>java.lang.String</value-type> </event-definition> </portlet-app>
  • 6. Step 5: A portlet can read public render parameter using following method request.getPublicParameterMap() Note: Public render parameters are merged with regular parameters so can also be read using request.getParameter(“id1”); Step 6: A portlet can remove a public render parameter by invoking following methods response.removePublicRenderParameter(“id1”) Step 7: Make view.jsp for sender and receiver Make view.jsp in html/sender/view.jsp View.jsp <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> <portlet:defineObjects /> vbjhbnj <p>Click the link below to pitch the ball. </p> <a href="<portlet:actionURL name="pitchBall"></portlet:actionURL>">Pitch!</a> Make view.jsp in html/recevier/view.jsp View.jsp <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> <portlet:defineObjects /> <% String pitch = (String)renderRequest.getParameter("ipc.pitch"); %> <p>And the pitch is....</p> <p> <% if (pitch!=null) { %> <%=pitch %>! <% } else { %> ... waiting for pitch. <% } %> Step 8: now deploy it and check it Liferay development is not at all an simpley task as it requires a expetise with vast experience. Attune Infocom is one of the fastest growing Liferay development firms, which has an extremely talented pool of liferay developers who can develop custom liferay portals for you. Attuene Infocom offer outsource Liferay Portal development solution at worldwide.