Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Micael Ericsson
Problem retrieving article
August 9, 2017 6:55 AM
Answer

Micael Ericsson

Rank: Regular Member

Posts: 156

Join Date: December 11, 2012

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:
1   
2FacesContext context = FacesContext.getCurrentInstance();
3PortletRequest portletRequest = (PortletRequest) context.getExternalContext().getRequest();
4ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
5long groupId = themeDisplay.getCompanyGroupId();
6JournalArticle 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:
1JournalArticle 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
RE: Problem retrieving article
August 9, 2017 7:24 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2499

Join Date: July 26, 2005

Recent Posts

Hi Micael,

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

Kind Regards,

Neil