Foros de discusión

How to invoke a portlet class method using AJAX call?

Satheesh Ravi, modificado hace 12 años.

How to invoke a portlet class method using AJAX call?

Junior Member Mensajes: 35 Fecha de incorporación: 25/11/11 Mensajes recientes
I am trying to access DB from my portlet class on load of portlet's view.jsp page. For that I need to make an ajax call.I am able to access other web pages using ajax. I don't know how to call a java method using AJAX. I am using liferay 6.0. Looking forward for some help. Thanks in advance
thumbnail
Ravi Kumar Gupta, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Liferay Legend Mensajes: 1302 Fecha de incorporación: 24/06/09 Mensajes recientes
See this portlet should help you. http://sourceforge.net/projects/ajaxjqueryportl/files/
thumbnail
Nagendra Kumar Busam, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
If it is a custom method - I hope it's not possible. As per portal spec you can invoke serveResource method using AJAX
Satheesh Ravi, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Junior Member Mensajes: 35 Fecha de incorporación: 25/11/11 Mensajes recientes
What is serveResource method? Can you provide a tutorial or a link regarding serveResource method?
thumbnail
Ravi Kumar Gupta, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Liferay Legend Mensajes: 1302 Fecha de incorporación: 24/06/09 Mensajes recientes
thumbnail
David García González, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Regular Member Mensajes: 127 Fecha de incorporación: 14/07/09 Mensajes recientes
You can implement an interface and a method and then use DWR.

It is very easy!!


http://directwebremoting.org/dwr/index.html
thumbnail
Raja Seth, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
Yes DWR is much better for use... Thanks David... :-)
thumbnail
Juan Carrey Labarta, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Junior Member Mensajes: 31 Fecha de incorporación: 15/08/11 Mensajes recientes
Portlet specification specifies several different portlet request types

Render - Renders html
Action - Performs an action
Resource - Serves any kind of resource (documents, json, html, ... )

Resource is the way you go for what you ask.

If you are using MVCPortlet , you can override the empty method :

void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)

which writes in the ResourceResponse in the same way you would do for a HttpServletResponse, and will be accessible as a Rest service.

Then in the JSP (if you are using jsp for rendering your page), you can use the portlet:resourceURL taglib or liferay-portlet:resourceURL using the resourceId (identifies uniquely the serveResource operation) to create the URL to call the server thought this rest service you have just created.

DWR is much complex for him, as he didn't yet know what "serveResource" means. Don't think this is what he is looking for.
Satheesh Ravi, modificado hace 12 años.

RE: How to invoke a portlet class method using AJAX call?

Junior Member Mensajes: 35 Fecha de incorporación: 25/11/11 Mensajes recientes
Thanks a lot Juan. I figured it out from the portlet specification. However I was looking for something like this.