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 :

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





JSP File :

<%
String content = StringPool.BLANK;
try{
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 %>


                                 OR 

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...