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.
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");
If Portlet B does not need to perform server-side logic, then you could simply use pub/sub on the client and have Portlet B listen to a particular event that Portlet A will publish.
So flow is:
Using pub/sub in this way decouples the portlets from each other. If Portlet A does not exist, Portlet B does not break. If Portlet B does not exist, Portlet A does not break.
And if Portlet C comes along and also is capable of acquiring MyData, this portlet could also start publishing "MyDataUpdated" events, and Portlet B will start to get these events too. It gets the new updates for free!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.