Wednesday, May 15, 2013

How to turn on ServiceLocator of Velocity in Liferay

Today, when I create a velocity template to generate menu to some static articles, I have to use ServiceLocator to get JournalArticleLocalService, but it seem nothing happens. After searching for longtime, I see that there is no error in code, but it doesn't work. Then I know that I didn't turn on variable serviceLocator for Velocity. To turn it on, please insert "journal.template.velocity.restricted.variables=" in file portal-ext.properties in liferay\tomcat-7.0.27\webapps\ROOT\WEB-INF\classes. Hope that this is solve your problem. Now this command works well: $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService")

No comments: