2014-09-22 60 views
0

我有一個eclipse中的portlet項目列表,比如說20(新的也許將來或者未來)。Liferay - portlet之間的客戶端通信

我想要做的是:

  • 創建新的portlet,將聽取所有按鈕的交互 上所有20個左右的portlet
  • 顯示的結果(成功或失敗)使用我剛剛創建的這個portlet。

我試圖尋找IPC,但他們都有一個例子,其中一個portlet發射一個事件,不止一個正在偵聽,但我想做的事情反之亦然。

我們該如何做到這一點?有什麼建議麼?

回答

4

您正在尋找客戶端IPC。所以,你需要做的是,你可以有多個事件與

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

火事件將發送者的portlet被解僱綁定,您可以從多個portlet的多個觸發事件。 要監聽那些需要liferay.on的事件,無論是在單個portlet還是在多個portlet中。 您可以使用下面的格式和樣本代碼

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) 
}); 

欲瞭解更多信息,你可以通過以下鏈接搭起多個事件在接收器的portlet JSP(S)。 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