Total Pageviews

Friday, September 28, 2012

LIferay - Using Custom Portlet Services in EXT

Using custom portlet services in theme velocity templates is very easy and ServiceLocator class provides an overloaded method for the same. (See this for example), but for using them in ext is difficult because this class cannot be used in ext. I searched in forum but found only one solution which was suggesting to move the portlet service jar to global class-loader. This solution was working for me as well, but I was thinking not to move jar, instead trying to achieve it by some other way.

So, I tried a few things and the following code snippet worked for me:
For the above mentioned code, consider "example-portlet" is servlet context name, and we are invoking exampleFunction(long userid) method from com.apoorva.portlet.service.ExampleLocalService class, with the following imports:
Hope this will help you some day.