Liferay Inter-portlet communication(client side)

来源:互联网 发布:最靠谱的二手交易软件 编辑:程序博客网 时间:2024/06/05 07:46

It's very easy to do that. Liferay provides script to do that.

This is the syntax:

 Liferay.fire(eventName, data) Liferay.on(eventName, function, [scope])

In my case, one portlet just sends an event out. The other portlet only needs to refresh itself.

Liferay.fire('iFramePortletReload', 'iFramePortletReload');


Liferay.on('iFramePortletReload', function(event, data) {
window.location.reload();
//Liferay.Portlet.refresh('#p_p_id<portlet:namespace />');
});


window.location.reload(); // When I use this script, actually it'll refresh the current liferay page not only the portlet which receives the event. 

Liferay.Portlet.refresh('#p_p_id<portlet:namespace />'); // this statement will only refresh current portlet which receive the event.