Freemarker不分配staticUtil [英] Freemarker does not assign staticUtil
问题描述
我在liferay 6.2上处理了应用程序显示模板,我使用freemarker帮助分页了liferay的动态数据列表.当我升级到liferay 7时,这是一个问题. Liferay 7使用代码<#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)>
来获取记录.
I worked Application Display Templates on liferay 6.2, I use freemarker help pagination the dynamics data list of liferay. When I upgrade to liferay 7, it is a problem. Liferay 7 use code <#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)>
for get a records.
旧代码:
<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")> <#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)> <#assign totalRecord = DDLRecordLocalService.getRecordsCount(reserved_record_set_id, 0) >
<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")> <#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)> <#assign totalRecord = DDLRecordLocalService.getRecordsCount(reserved_record_set_id, 0) >
它不起作用.
所以我尝试<#assign serviceLocator = staticUtil["com.liferay.portal.template.ServiceLocator"]>
,但是staticUtil
遇到错误.
So I try <#assign serviceLocator = staticUtil["com.liferay.portal.template.ServiceLocator"]>
but staticUtil
get an error.
以下内容评估为null或丢失: ==> staticUtil [在第9行第27列的模板"20115#20159#21387"中] 提示:如果已知失败的表达式在法律上是指有时为空或缺失的内容
The following has evaluated to null or missing: ==> staticUtil [in template "20115#20159#21387" at line 9, column 27] Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing
在portal-ext.properties中,我添加了:
In portal-ext.properties I have added:
freemarker.engine.restricted.classes=
freemarker.engine.restricted.packages=
freemarker.engine.restricted.variables=
推荐答案
您引用的属性已移至Liferay 7/DXP中的OSGI配置.
要部署它们,您需要创建一个名为 com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.cfg 的文件,并将其放置在
The properties you refer to have been moved to an OSGI config in Liferay 7/DXP.
To deploy them you need to create a file named com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration.cfg and place it under $LIFERAY_HOME/osgi/configs
文件内容如下:
restrictedVariables=
要查找所有配置及其默认设置,请查看类com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration
To find all the configs and their defaults you can have a look at the class com.liferay.portal.template.freemarker.configuration.FreeMarkerEngineConfiguration
您可以在Liferay源代码中找到.
That you can find in the Liferay source code.
这篇关于Freemarker不分配staticUtil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!