Reputation: 7662
A simple example:
/* Get user roles */
#set($userId=$request.attributes.get('USER_ID'))
#set($roleLocalService=$serviceLocator.findService("com.liferay.portal.service.RoleLocalService"))
$roleLocalService.getUserRoles($userId)
What renders on the page is just the text with no data.
$roleLocalService.getUserRoles($userId)
What am I missing?
Upvotes: 1
Views: 143
Reputation: 368
serviceLocator
. The default value in portal.properties
is velocity.engine.restricted.variables=serviceLocator
which means serviceLocator
is not available to templates. Set it to "blank" (or at least do not include serviceLocator
). For example, set it to velocity.engine.restricted.variables=
in a portal-ext.properties
file inside the Liferay Home directory.
$request.attributes.get
is going to give you the String value of the userId. So you need to convert this to a Long using something like:$roleLocalService.getUserRoles($getterUtil.getLong($userId))
Upvotes: 3