Foren

Problem retrieving article

Micael Ericsson, geändert vor 6 Jahren.

Problem retrieving article

Regular Member Beiträge: 169 Beitrittsdatum: 11.12.12 Neueste Beiträge
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
thumbnail
Neil Griffin, geändert vor 6 Jahren.

RE: Problem retrieving article

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Micael,

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

Kind Regards,

Neil