Foros de discusión
Problem retrieving article
Micael Ericsson, modificado hace 6 años.
Problem retrieving article
Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
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:
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:
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:
This didn't work either:
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.
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.
Neil Griffin, modificado hace 6 años.
RE: Problem retrieving article
Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,
I recommend that you try themeDisplay.getScopeGroupId() instead.
Kind Regards,
Neil
I recommend that you try themeDisplay.getScopeGroupId() instead.
Kind Regards,
Neil