Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Error in Template Freemaker 7.4
Hello everyone,
in Liferay 7.1 I used this piece of code in an
FTL Template to get users to print and it worked.
<#assign UserLocalService =
serviceLocator.findService("com.liferay.portal.kernel.service.UserLocalService")>
<#assign users = UserLocalService.getUsers(0,10)>
<br/>
<#list users as user>
${user}
</#list>
Now I tried in Liferay DXP 7.4 and it doesn't work anymore,
telling me:
The following has evaluated to null or missing:
==> serviceLocator [in template
"4573561063168409277#20119#32927" at line 1, column 29]
How has it changed in DXP and what do I replace it with?
thanks,
F
Hi,
You can try removing serviceLocator from restricted varibles list.
System Setting -> Template Engines -> here u need remove "serviceLocator" from restricted variable list.
Hi Francesco,
If it's possible try to avoid usage of serviceLocator but if it's
really needed then on top removing "serviceLocator" from
restricted variable list you also need to add
"com.liferay.portal.kernel.service.UserLocalService"
in the