Monday 28 October 2013

Accessing custom service in theme

Follow the bellow steps to access Custom Service in liferay Theme.

1. Build your service and deploy the portlet into liferay portal.

2. set the bellow portal property value empty, by default it holds serviceLocator

journal.template.velocity.restricted.variables=

3. in vm file where you want to access the service, write the bellow line of code
 
#set($customLocalService=$serviceLocator.findService('your portlet name'),'package.entityLocalservice')

in the above code
  i.customLocalService  is the Custom Variable (User Defined)
  ii. your portlet name is the portlet name,  if you mentioned the portlet name means it will help the service locator to to find the service with in the portlet, ( i.e the portlet name you mentioned), if you pass empty values than service locator will search the service with portal.
 iii. Package is the package path of the service
 iv. entityLocalservice is the local service name

4.after the step 3, variable customLocalService,  will hold the reference of localservice impl class by using this you can access all the method in local service impl class.

I hope this blog may help you............................