Forums

angle-left Back

Problem retrieving article

ME
Micael Ericsson, modified 11 Months ago.

Problem retrieving article

Regular Member Posts: 163 Join Date: 12/11/12 Recent Posts
I have created an article for our site. Now I wish to retrieve the content of that article in my JSF portlet.
The article ha title "Stoppmeddelande". First try was to get the article was with the following code:
   
FacesContext context = FacesContext.getCurrentInstance();
PortletRequest portletRequest = (PortletRequest) context.getExternalContext().getRequest();
ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
long groupId = themeDisplay.getCompanyGroupId();
JournalArticle article = JournalArticleServiceUtil.getArticleByUrlTitle(groupId, STOPP_MEDDELANDE);

Running this I got a PortalException with information that article with group xx and title 'Stoppmeddelande' could not be found.
Looking at my article in admin of site I found the following information in the url:
https://.....Dview%26doAsGroupId%3D20182%26refererPlid%3D20176%26controlPanelCategory%3Dsites&_15_groupId=20182&_15_folderId=0&_15_articleId=45085&_15_status=0

The displayed groupid was not matching the one I used getting the article. At least not according to the exception.
Next try was to get Article with above groupid and articleid:
JournalArticle article = JournalArticleServiceUtil.getArticle(201182L, "45085");

This didn't work either:
No JournalArticle exists with the key {groupId=201182, articleId=45085, status=8}


What am I doing wrong here?

Liferay 6.2, JSF 2.2 portlet. I am not sure why I use themeDisplay but the sample found on internet was using it. emoticon
Neil Griffin, modified 11 Months ago.

RE: Problem retrieving article

LIFERAY STAFF Liferay Legend Posts: 2540 Join Date: 7/26/05 Recent Posts
Hi Micael,

I recommend that you try themeDisplay.getScopeGroupId() instead.

Kind Regards,

Neil