简体   繁体   English

utilLocator.findUtil(“com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil”)未定义

[英]utilLocator.findUtil(“com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil”) is undefined

I am using the below code in ADT custom template code 我在ADT自定义模板代码中使用以下代码

<#assign storageEngineUtil = utilLocator.findUtil("com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil") />

But this is giving utilLocator.findUtil("com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil") is undefined 但是这给了utilLocator.findUtil("com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil") is undefined

Is there anything I'm missing here? 这里有什么我想念的吗? but

The util class AssetEntryLocalServiceUtil is not accessible from a Freemarker template. 无法从Freemarker模板访问util类AssetEntryLocalServiceUtil

What you're trying to do is to get access to AssetEntryLocalService . 您要做的是访问AssetEntryLocalService Access to Liferay services is restricted in ADT templates. 在ADT模板中限制访问Liferay服务。

You can get instance to AssetEntryLocalService through ServiceLocator , but you have to tell Liferay to allow it. 您可以通过ServiceLocator将实例获取到AssetEntryLocalService ,但您必须告诉Liferay允许它。

Default configuration restricts access to serviceLocator variable (in portal.properties ). 默认配置限制对serviceLocator变量的访问(在portal.properties )。

#
# Set a comma delimited list of variables the FreeMarker engine cannot
# have access to. This will affect Dynamic Data List templates, Journal
# templates, and Portlet Display templates.
#
freemarker.engine.restricted.variables=serviceLocator

The setting needs to be overridden to empty value in portal-ext.properties (ie. allow the usage of serviceLocator in templates). 需要在portal-ext.properties设置覆盖为空值(即允许在模板中使用serviceLocator )。

Then you can finally call serviceLocator.findService to get the service. 然后,您最终可以调用serviceLocator.findService来获取服务。

<#assign assetEntryLocalService = serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService") />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM