Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pablo Rendón
Generic Inter Portlet Communication
July 30, 2012 12:55 PM
Answer

Pablo Rendón

Rank: New Member

Posts: 8

Join Date: December 29, 2011

Recent Posts

Hello everyone,

I'm trying to figure it out if there are some way to generalize the communication between generic liferay portlets and my portlets, let me explain the situation:

let's say that I have a portlet (Developed by me) that shows some information in my home page, and I have on the same page an instance of the generic Blog portlet.

what I'm trying to do by IPC is create a "Listener" in my portlet and somehow trigger an action when some event happens in the blog portlet, for example if somebody publish a new entry in my blog I can show information related to the publisher in my custom portlet.

the question is how can I do this without modifying the generic liferay portlets? (blog for example)

is there a way to generalize this kind of IPC in order to standardize the communication between generic liferay portlets and my portlets?

Any help is really appreciated!
Hitoshi Ozawa
RE: Generic Inter Portlet Communication
July 30, 2012 2:50 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Do you mean something like a message bus in JSR portlet specification?
David H Nebinger
RE: Generic Inter Portlet Communication
July 31, 2012 6:13 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11305

Join Date: September 1, 2006

Recent Posts

Pablo Rendón:
the question is how can I do this without modifying the generic liferay portlets? (blog for example)


No. As you have seen, you must actually add code to your portlets in order to send/receive messages. Why would you think the canned portlets may be any different?
Pablo Rendón
RE: Generic Inter Portlet Communication
July 31, 2012 6:25 AM
Answer

Pablo Rendón

Rank: New Member

Posts: 8

Join Date: December 29, 2011

Recent Posts

Thanks for your answer,

I'm trying this approach because I want to maximize use of the canned portlets but I need them to interact with my own portlets, of course modifying the canned portlets is a solution but it means more development time and more coupling.

I'm still looking for the best approach...
David H Nebinger
RE: Generic Inter Portlet Communication
July 31, 2012 6:50 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11305

Join Date: September 1, 2006

Recent Posts

I guess it would depend upon the level of interactivity you need to get, but there are other possible solutions...

For example, sometimes you can add a model listener to the Liferay entities and use that information to handle changes. Other times it can be handled via just understanding the portlet life cycle (i.e. if your portlet is on the same page as a blog portlet, you will process a render request when something is submitted via the blog portlet).

Javascript event listeners were my first thought, but since a click on a button on the blog portlet results in a page submit, you'd have very little time to react to the javascript event.
Jay Patel
RE: Generic Inter Portlet Communication
July 31, 2012 7:57 AM
Answer

Jay Patel

Rank: Regular Member

Posts: 119

Join Date: February 23, 2010

Recent Posts

Hi Pablo,

IMHO the scenario what you want to implement (i.e. when new Blog is added you want to capture/show some information in your custom portlet) is not ideal IPC use-case. I would still suggest to utilize following solutions:

1. Since creating a new Blog entry is page submit/refresh event, you can pull up the data you require in your custom portlet's render phase. Because adding of Blog will be done in processAction phase of OOB Blog portlet.

2. Let's assume that when new blog entry is added you want to perform some additional actions like adding some custom data in your own table etc. then in that case you can write custom hooks with Model Listeners or Service-Overriding. For more info visit following link:
Hook in Liferay


3. As per my understanding, changes in the OOB portlets through ext should be kept as minimal as possible in order to avoid any future migration issues.

-Jay.
Pablo Rendón
RE: Generic Inter Portlet Communication
July 31, 2012 8:06 AM
Answer

Pablo Rendón

Rank: New Member

Posts: 8

Join Date: December 29, 2011

Recent Posts

Ok, this seems to be an option, probably not as generic as I would like but it could works... I'm going deep with this approach, I'll post my results.
however new ideas and suggestions are always welcome.

Thank you very much!
Gaurav Shirbhate
RE: Generic Inter Portlet Communication
October 2, 2012 7:02 AM
Answer

Gaurav Shirbhate

Rank: New Member

Posts: 24

Join Date: September 26, 2012

Recent Posts

I dropped two portlets on a same page. I displayed list of options on one portlet. when i click on any particular option the information about that particular option should be display on second portlet. This should happen with all the options. For that what i have to do, Please give me solution, Thanks.
Michael Bravo
RE: Generic Inter Portlet Communication
November 9, 2012 7:37 PM
Answer

Michael Bravo

Rank: New Member

Posts: 20

Join Date: April 26, 2012

Recent Posts

Hi Pablo,

I am developing on Liferay 6.1.2 EE and am looking for basic inter-portlet communication examples. For instance, we have a content template that has a set of links on the left and content on the right. When a link is selected on the left, the content changes for that particular link. Basic navigation....

I attached a screen grab of the page I described above.

Have you found any solutions for this type of functionality using inter-portlet communication?

Thanks in advance,
Mike
Pablo Rendón
RE: Generic Inter Portlet Communication
November 15, 2012 9:19 AM
Answer

Pablo Rendón

Rank: New Member

Posts: 8

Join Date: December 29, 2011

Recent Posts

Hello Michael,

One option is to use an small hook to modify the generic portlet in order to add the information you need in for example a hidden div or as a "rel" html attribute, so you can read this information with a Javascript framework such as jQuery (my favorite). and then use the front end inter-portlet communication that liferay provides, for example:

Triggering:
Liferay.fire('showFilteredUsers', {usersId: [1024,1151]});

Listening:
Liferay.on('filteredUsersMessage', function(event) {
alert('A message has been sent by ' + event.senderPortletId + ' Clicked UserId: ' + event.userId);
});


you can find a example of this here:
http://www.rotterdam-cs.com/tools/-/asset_publisher/piIpOr8rXNan/content/show-users-by-portlet

you can download the source and play around with it, I hope this could be helpful for you.

Best regards!