Liferay—Portlet之间的客户端通信



我在eclipse中有一个portlet项目列表,比如说20个(新的项目可能会在未来出现,也可能不会出现)。

我想做的是:

  • 创建一个新的portlet,它将监听所有按钮交互在所有这20个左右的Portlet上
  • 使用我刚刚创建

我试着研究IPC,但他们都有一个例子,一个portlet正在触发一个事件,而多个portlet正在侦听,但我想做一些相反的事情。

我们如何才能做到这一点?有什么建议吗?

您正在寻找客户端IPC。所以你需要做的是,你可以让多个事件与绑定

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

激发事件将由发送方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)
});

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

最新更新