我对Liferay中的portlet间通信有问题。 两个portlet通过事件进行通信。
发信人:
<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-event通过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-method为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它不会刷新整个页面,但通信工作正常。 使用按钮刷新整个页面,但通信无效。
有什么想法吗?
答案 0 :(得分:-1)
portlet规范的第一个版本JSR-168 / portlet1.0不包含对Inter Portlet Communication的任何支持。第二个版本,JSR-286 / portlet2.0,IPC机制支持。 使用JSR-286可以轻松地在两个portlet之间共享数据。使用IPC机制,我们可以共享从ACTION到VIEW阶段和VIEW-VIEW阶段的数据。
有关在Liferay中创建portlet的分步指南,您可以read here