Liferay-Portlet之间的客户端通信

use*_*248 1 portlet client-side liferay

我在Eclipse中有一份Portlet项目的清单,例如20(新的可能会在将来出现,或者可能不会)。

我想做的是:

  • 创建一个新的portlet,它将监听所有这20个左右的portlet上的所有按钮交互,并且
  • 使用我刚创建的此portlet显示结果(成功或失败)。

我尝试研究IPC,但它们都有一个示例,其中一个Portlet触发了一个事件,而一个以上的Portlet正在侦听,但反之亦然。

我们怎样才能做到这一点?有什么建议么?

Dan*_*ish 5

您正在寻找客户端IPC。因此,您需要做的是,可以将多个事件与

Liferay.fire(eventName, data)
Liferay.on(eventName, function, [scope])
Run Code Online (Sandbox Code Playgroud)

触发事件将由发送者portlet触发,您可以从多个portlet获得多个触发事件。要收听这些事件,您需要在单个portlet中或在多个portlet中都具有liferay.on。您可以使用以下格式和示例代码在接收器Portlet JSP中放置多个事件

Liferay.on('eventName',function(event) {
// write code to get the veluese that sent by sender portlet
});

Example code as follows in receiver portlet view.jsp

Liferay.on('getUserData',function(event) {
 alert('User Name:'+ event.name)
});
Run Code Online (Sandbox Code Playgroud)

有关更多信息,您可以通过以下链接。 http://www.liferaysavvy.com/2014/01/liferay-client-side-inter-portlet.html https://www.liferay.com/web/meera.success/blog/-/blogs/liferay-client -side-inter-portlet-communication-using-ajax http://www.liferay.com/community/wiki/-/wiki/Main/Inter-portlet+communication