我在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它不刷新整個頁面,但通信起作用。 用一個按鈕刷新整個頁面,但通信不起作用。
有什麼想法?