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%>"

Rate Me:

Create Servlet Project as Module

You would have seen that many times we are writing out own servlet in Liferay portal to achieve some specific use case. In DXP, You can st...