Liferay 7 JournalArticleLocalServiceUtil不会返回articleDisplay内容

时间:2018-04-09 14:47:05

标签: templates liferay osgi freemarker

我正在使用Liferay 7 GA5,而我正在开发OSGI模块。 我使用以下代码开头的工作freemarker模板编写了我的Web内容:

<#assign serviceContext = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"].getServiceContext()>
<#assign themeDisplay = serviceContext.getThemeDisplay() />

现在我需要以编程方式访问Web内容,但是如果我从portlet访问:

JournalArticleDisplay articleDisplay = 
                JournalArticleLocalServiceUtil.getArticleDisplay(themeDisplay.getScopeGroupId(), articleId, null, themeDisplay.getLanguageId(), themeDisplay);

        String title = articleDisplay.getTitle();
        String content = articleDisplay.getContent();
     ...

内容字符串包含此错误:

 <div class="journal-template-error">
  <span class="alert alert-error">
     Si è verificato un errore nell'elaborarazione del modello.    </span>

 <pre>No error description was specified for this error; low-level message: java.lang.ClassNotFoundException: com.liferay.portal.kernel.service.ServiceContextThreadLocal cannot be found by com.liferay.portal.template.freemarker_2.0.27

----
FTL stack trace (&quot;~&quot; means nesting-related):
- Failed at: #assign serviceContext = staticUtil[&quot;...  [in template &quot;10135#10168#MODELLOXXX&quot; at line 1, column 1]
----</pre>

这意味着com.liferay.portal.kernel.service.ServiceContextThreadLocal在此上下文中不可用于freemarker:如何使其可用。另一种解决方案是通过动态地将另一个模板应用于Web内容来解决这个问题:是否可能?

0 个答案:

没有答案