26 April, 2012

Display web content in JSP Page

In many liferay projects we are having a requirement to fetch web content and show as per specific location.
If you are thinking to display web content in JSP page, just 2-3 steps far you are :

portal-ext.properties :

no.actical.text=No Article Exists with this name.

JSP File :

String content = StringPool.BLANK;
String articleName = PropsUtil.get("acticle.name");

JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle (themeDisplay.getScopeGroupId(), articleName);
String articleId = journalArticle.getArticleId();
JournalArticleDisplay articleDisplay =  JournalContentUtil.getDisplay (themeDisplay.getScoprGroupId(), articleId,"","",themeDisplay);
content = articleDisplay.getContent();
}Catch(Exception e){
content = PropsUtil.get("no.article.text");

<%= content %>


Simply use in LR 6 

<liferay-ui:journal-article showTitle="false" articleId="<%= journalArticleId%>"

Popular Posts

Featured Post

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...