jspliferayliferay-7liferay-aui

How to render Asset Entry content in a JSP in Liferay 7


I have created a "basic web content" entry in my liferay. In Asset Publisher, I can display it via the following:

<liferay-ui:asset-display
    assetEntry="<%= assetEntry %>"
    assetRenderer="<%= assetRenderer %>"
    assetRendererFactory="<%= assetRendererFactory %>"
    showExtraInfo="<%= assetPublisherDisplayContext.isShowExtraInfo() %>"
/>

But that means I have no control over the content. So, I wanted to get the content using the following:

JournalArticleLocalService.getArticle(assetEntry.getClassPK());

However, that throws an error: No JournalArticle exists with the primary key 58637. Thoughts? Any help?

I am assuming that Web Content Article means Journal Article, since I haven't found any web content service.


Solution

  • Concerning your error: An journal AssetEntry references an JournalArticle by its resourcePrimKey which is not the primary key of the JournalArticle you are going to use in JournalArticleLocalService.getArticle(long). A reason is that JournalArticles are versioned. You can try to do the following: JournalArticleLocalService.fetchLatestArticle(assetEntry.getClassPK()); to fetch the latest journal article version.