0
votes

I have a problem with the inter-portlet-communication in Liferay. Two portlets are communicating through Events.

Sender:

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

Listener:

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

Event:

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

Sender-Portlet:

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

The onclick-event calls a ProcessAction-method via ajax call.

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

           },
       });

And the ProcessAction-method setting a Event for Commincation.

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

So the Listener-Portlet receives this event in the ProcessEvent-method.

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

My Problem is that i need the jsonString in javascript. With an onclick-Event it doesn't refresh the whole page, but the communication works. With an button it refresh the whole page, but the communication doesn't works.

Any idea?

1

1 Answers

-1
votes

The first version of the portlet specification, JSR-168/portlet1.0, did not include any support for Inter Portlet Communication. The second version, JSR-286/ portlet2.0, which is supported for IPC Mechanism. IPC is made easy with JSR-286 to share the data between two portlets. Using IPC mechanisms, we can share the data from ACTION to VIEW phase and VIEW-VIEW Phase.

For step-by step guideline for creating portlet in Liferay, you can read here