Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Path Finder LifeRay
calling portlet from another portlet
18. April 2012 03:36
Antwort

Path Finder LifeRay

Rang: Expert

Nachrichten: 262

Eintrittsdatum: 18. September 2009

Neue Beiträge

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
18. April 2012 05:56
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11285

Eintrittsdatum: 1. September 2006

Neue Beiträge

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
20. April 2012 03:29
Antwort

Path Finder LifeRay

Rang: Expert

Nachrichten: 262

Eintrittsdatum: 18. September 2009

Neue Beiträge

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
20. April 2012 04:21
Antwort

Riccardo Ferrari

Rang: Regular Member

Nachrichten: 137

Eintrittsdatum: 13. November 2010

Neue Beiträge

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
20. April 2012 05:10
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11285

Eintrittsdatum: 1. September 2006

Neue Beiträge

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
27. April 2012 19:28
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7949

Eintrittsdatum: 23. März 2010

Neue Beiträge

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
28. April 2012 10:34
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11285

Eintrittsdatum: 1. September 2006

Neue Beiträge

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.