1/06/2014

How to render a WebContent programmatically

Sometimes you might want to render a WebContent programmatically. Maybe because you want to include it in a portlet or maybe you are not able to use the liferay journal-article taglib. There is a very easy solution that you can use in every JSP portlet. I took it from the taglib, so the credit doesn´t really belong to me ;)


JournalArticleDisplay articleDisplay = 
JournalContentUtil.getDisplay(groupId, articleId, templateId, null, languageId, themeDisplay, articlePage, xmlRequest);

<%= RuntimePortletUtil.processXML(application, request, response, renderRequest, renderResponse, articleDisplay.getContent()) %>


If you have any questions, feel free to leave a comment.