Forums de discussion

method setEvent(QName, String) is undefined for the type ResourceResponse

thumbnail
Ram Dev, modifié il y a 11 années.

method setEvent(QName, String) is undefined for the type ResourceResponse

Junior Member Publications: 46 Date d'inscription: 29/06/11 Publications récentes
Hi

I am using Liferay 6.1 Version .
Here i am trying to Implement Inter Portlet Communication .


When I am calling Ajax function to resource server method its getting all data ,
in that method but when everything is done , i want to show that response in my Another Portlet


Here this is what i tried till now .

Here is my view.jsp which makes an Ajax call

function addToDo(addToDo){
	
    var todo =document.getElementById('toDo').value;
    $.ajax({
        url :addToDo,            
          data: {"todo":todo,"CMD":"addToDo"},
          type: "GET",
          dataType: "text",
        success: function(data) {              

        	alert(data);
        }
    });
}



Here is i made changes to portlet.xml file
<portlet>
 <supported-publishing-event xmlns:x="http://liferay.com">
                <qname>x:empinfo</qname>
            </supported-publishing-event>
</portlet>

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


This is my serveResource Method



public class AjaxPortletTest extends MVCPortlet {
	
	@Override
	public void serveResource(ResourceRequest request, ResourceResponse response) throws IOException{
		
		   javax.xml.namespace.QName qName = new QName("http://liferay.com", "empinfo", "x");
// In the below line i am getting Compiletime Error .
		   response.setEvent(qName, "Hi! You have received Event Data sent from Sender Portlet");

	}
 }


But i am getting a Compiletime error saying that

The method setEvent(QName, String) is undefined for the type ResourceResponse

Please help me in how to implement IPC using Events in my case .