Calling service classes in from webcontent
Follwing URL gives what are the variables can be access in the CMS template.
- http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Internal+API
- http://www.liferay.com/es/community/wiki/-/wiki/Main/Access+Objects+from+Velocity
- http://www.liferay.com/web/raymond.auge/blog/-/blogs/custom-velocity-tools-and-liferay-6-0
- If we see the $request output, it gives manythings.
Some it requires to access the services from the custom portlet . We need to add property in portal-ext.properties.
If we find the "journal.template.velocity.restricted.variables" it contains key value as serviceLocator. Whenever we are adding the property in a file we need to remove the "serviceLocator" form below and add it as below.
#
# Input a comma delimited list of variables which are restricted from the
# context in Velocity based Journal templates.
#
journal.template.velocity.restricted.variables=
After restarting the server we can access the services like $serviceLocator.findService(-----)
#set ($userLocalService= $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($user = $userLocalService.getUserById($request.get("theme-display").get("user-id")))
#set ($emailAddress = $user.getEmailAddress())
Comments
Post a Comment