2013-04-18 44 views
0

我在Liferay中的portlet間通信有問題。 兩個portlet通過Events進行通信。Portlet間通信 - Liferay

發件人:

<supported-publishing-event xmlns:x='http://liferay.com'> 
    <qname>x:aufgabeInfo</qname> 
</supported-publishing-event> 

監聽器:

<supported-processing-event xmlns:x='http://liferay.com'> 
    <qname>x:aufgabeInfo</qname> 
</supported-processing-event> 

事件:

<event-definition xmlns:x='http://liferay.com'> 
    <qname>x:aufgabeInfo</qname> 
    <value-type>java.lang.String</value-type> 
</event-definition> 

發件人的Portlet:

<a onclick="selectedEntry('${aufgabe.aufgabenName}', '${aufgabe.aufgabenID}');"> 
    ${aufgabe.aufgabenName} </a><br/> 

onclick事件通過ajax調用調用ProcessAction方法。

function selectedEntry(name, id){ 
    console.log("in click"); 
    var url = '<portlet:actionURL name="open"/>'; 
     $.ajax({ 
      type: "POST", 
      url: url, 
      data: {"name": name, "ID": id}, 
      dataType: "json", 
      success: function(){ 
       console.log("in success"); 

      }, 
     }); 

並且ProcessAction-方法設置了一個用於Commincation的事件。

QName qName = new QName("http://liferay.com", "aufgabeInfo", "x"); 
actionResponse.setEvent(qName, jsonString); 

所以Listener-Portlet在ProcessEvent方法中接收到這個事件。

Event event = request.getEvent(); 
String jsonString = (String) event.getValue(); 

我的問題是,我需要JavaScript中的jsonString。 使用onclick-Event它不刷新整個頁面,但通信起作用。 用一個按鈕刷新整個頁面,但通信不起作用。

有什麼想法?

回答

-1

Portlet規範的第一個版本JSR-168/portlet1.0不包括對Inter Portlet通信的任何支持。第二個版本是JSR-286/portlet2.0,它支持IPC機制。 使用JSR-286可以輕鬆實現IPC,以在兩個Portlet之間共享數據。使用IPC機制,我們可以將ACTION中的數據共享到VIEW階段和VIEW-VIEW階段。

對於在Liferay中創建portlet的分步指南,您可以使用read here