Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Path Finder LifeRay
calling portlet from another portlet
April 18, 2012 3:36 AM
Answer

Path Finder LifeRay

Rank: Expert

Posts: 262

Join Date: September 18, 2009

Recent Posts

Hi All,

I have a webcontent portlet where i placed images and links in that portlet when i click on the link there i need to get response in the another which may be not necessarily webcontent

how to do this please give answer

Thanks
David H Nebinger
RE: calling portlet from another portlet
April 18, 2012 5:56 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7076

Join Date: September 1, 2006

Recent Posts

Well normally portlet to portlet is IPC and you'd use that for the mechanism, but since you're in the web content portlet that won't be an option.

There is, however, a javascript version of IPC that is unique to Liferay. The LiferayIPC add-on for Vaadin uses it to allow communication between Vaadin portlets, but it leverages the same Javascript object.

I'd do some research along these lines as it should be something that you can do within the web content, yet still deal w/ events in the target.
Path Finder LifeRay
RE: calling portlet from another portlet
April 20, 2012 3:29 AM
Answer

Path Finder LifeRay

Rank: Expert

Posts: 262

Join Date: September 18, 2009

Recent Posts

Thanks David

please do this favor and i will wait for the reply.....and if you could tell the simple customization that would in fact be helpful to many people...

thanks
pathfinder
Riccardo Ferrari
RE: calling portlet from another portlet
April 20, 2012 4:21 AM
Answer

Riccardo Ferrari

Rank: Regular Member

Posts: 137

Join Date: November 13, 2010

Recent Posts

Hi,

you can try to set a Liferay.fire on the links you that you want to fire an event editing the proper WebContent. This allows you to achieve Client Side IPC. Of course you need that the other portlet is listening to that event (Liferay.on(...))

Regards,

R
David H Nebinger
RE: calling portlet from another portlet
April 20, 2012 5:10 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7076

Join Date: September 1, 2006

Recent Posts

Hmm, should have considered my wording... When I said "I'd do some research", I meant that "if it were me I'd start with research", not that I'd do the research...

But since I'm now on the hook for it, I'll find something for you today...
Hitoshi Ozawa
RE: calling portlet from another portlet
April 27, 2012 7:28 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

But since I'm now on the hook for it, I'll find something for you today...


So, did you find something? emoticon
David H Nebinger
RE: calling portlet from another portlet
April 28, 2012 10:34 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7076

Join Date: September 1, 2006

Recent Posts

Well, basically in javascript you plug into the Liferay event handling mechanism.

First you'll register a listener function with Liferay:

1// register a listener w/ Liferay
2Liferay.on("myEventId", function(eventId, data) {
3  // do whatever you need to within this function.
4});


In this case myEventId is the string for the event you want to get notified on. You want to choose your event ids wisely, so you don't collide with other possible listeners going on. For example, if your event id was "update" it would be quite easy to collide with some other portlet or even a Liferay event listener.

Now, to send an event you'll still use the javascript Liferay API:

1Liferay.fire("myEventId", "my important data");


Here the event id is the same event that you registered. Data should be a string of data that you want to send.

So one (or more) portlet(s) would register a listener, and one or more portlets on the page can fire events for the listening portlet(s).

Note that this form of IPC is limited to use of portlets on the same page, the current page the user is on.

Now Vaadin (which I'm using) is based upon GWT, so when I'm using the VaadinIPCforLiferay addon, through the magic of the javascript handling, my listeners actually call back directly to my java code in a totally transparent manner.

If you're not using Vaadin/GWT, you're going to have to build the appropriate javascript in the listener to invoke actions in your portlet on your own.