Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is AJAX for inter portlet communication possible?

I know that you can create portlets that can refresh its content without refreshing the whole portal page by simply using the JSR286 resourceURL tag and doing an AJAX call.

My question is, is it possible to do an AJAX call in Portlet A and somehow target and dynamically update Portlet B instead?

The idea is to avoid the who portal page refresh (re-rendering) when you do inter-portlet communication via actionURL or events.

like image 634
Mark Logan Avatar asked Mar 01 '11 17:03

Mark Logan


1 Answers

You may use jQuery trigger() and bind() methods to communicate between portlets. With this approach all communication will happen on clientside (browser) without any server interaction.

The portlet B that listens to the event should do something like:

$(document).bind("myevent", function(event, param) {
     // do your work here
     alert("message recieved with data " + param);
});

The portlet A that fire the event should do the following:

$(document).trigger("myevent", "mydata");
like image 124
Hasith Avatar answered Oct 18 '22 15:10

Hasith