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?
serviceLocator. The default value inportal.propertiesisvelocity.engine.restricted.variables=serviceLocatorwhich meansserviceLocatoris not available to templates. Set it to "blank" (or at least do not includeserviceLocator). For example, set it tovelocity.engine.restricted.variables=in a
portal-ext.propertiesfile inside the Liferay Home directory.$request.attributes.getis 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))