Some time we need to display journal article into our custom jsp not from the web content display portlet.
Following is the code snippet for fetching the journal article and display it into the custom.jsp
1)Code for the controller of the portlet.
Then get the journal article display object for the journal article
set the article display object
On the jsp side.
Following is the code snippet for fetching the journal article and display it into the custom.jsp
1)Code for the controller of the portlet.
JournalArticle article = null;
JournalArticleDisplay display = null;
article = JournalArticleLocalServiceUtil.getArticleByUrlTitle(themedisplay.getScopeGroupId(), formatUrlTitle(name));
Function for getting the formatted url title.
private String formatUrlTitle(String name){
return name.toLowerCase().replaceAll(" ","-");
}
return name.toLowerCase().replaceAll(" ","-");
}
Then get the journal article display object for the journal article
display = JournalArticleLocalServiceUtil.getArticleDisplay(themedisplay.getScopeGroupId(),article.getArticleId(),WebKeys.WINDOW_STATE,themedisplay.getLanguageId(),themedisplay);
set the article display object
request.setAttribute("post_of_the_week", article);
On the jsp side.
<%
JournalArticleDisplay display = (JournalArticleDisplay)renderRequest.getAttribute("post_of_the_week");
%>
<%=display.getContent() %>