Access Custom Portlet Service in Velocity Template

To know how to access Liferay service in Velocity template look at this post .

Here are the steps to access services of custom portlet in velocity template.

1) Make sure the services which you want to access are available inside tomcat/lib/ext.

2) In order to access services you need to place below property inside portal-ext.

By default this property will be like this
journal.template.velocity.restricted.variables=serviceLocator

Which means you wont be able to access serviceLocator inside velocity template.
So make sure before you access any service inside velocity template change this property to
journal.template.velocity.restricted.variables=

3) Access services using findService Method.


Normally we use findService(serviceName) method to access Liferay service.
But to access custom portlet service we have to use findService(contextName,ServiceName).

findService(serviceName) will search at the portal level and findService(servletContextName , serviceName) will search at specified portlet level.

Next PostNewer Post Previous PostOlder Post Home