掲示板

ServiceContext in JSF Spring Portlet

9年前 に Stephane Franchamp によって更新されました。

ServiceContext in JSF Spring Portlet

New Member 投稿: 19 参加年月日: 14/08/07 最新の投稿
Hi,

Any Ideas how to get the ServiceContext in a Primefaces Portlet after submitting Button ?

I can't do ServiceContext serviceContext = ServiceContextFactory.getInstance(
Prospect.class.getName(), request);


because i don't have the request Action like jsp, i create new Instance: ServiceContext serviceContext = new ServiceContext(); and after that just serviceContext.getScopeGroupId()

but i get error com.liferay.portal.NoSuchGroupException: No Group exists with the primary key 0

Thanks
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: ServiceContext in JSF Spring Portlet

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
The following should work in a JSF/PrimeFaces portlet:

FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
ServiceContext serviceContext = ServiceContextFactory.getInstance(Prospect.class.getName(), request);


If you still get the same "No Group exists with the primary key 0" error, then I recommend trying:

LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
ServiceContext serviceContext = liferayFacesContext.getServiceContext();
9年前 に Stephane Franchamp によって更新されました。

RE: ServiceContext in JSF Spring Portlet

New Member 投稿: 19 参加年月日: 14/08/07 最新の投稿
Thanks Neil,

It resolve my probleme, but i get new error in my code just i want to integrate Activiti Workflow, with my custom Entry :

[LiferayGroupsUtil:87] Cannot assign task to role Community Content Reviewer
com.liferay.portal.NoSuchRoleException: No Role exists with the key {companyId=10155, name=Community Content Reviewer}
at com.liferay.portal.service.persistence.RolePersistenceImpl.findByC_N(RolePersistenceImpl.java:5597)
at com.liferay.portal.service.impl.RoleLocalServiceImpl.loadGetRole(RoleLocalServiceImpl.java:1162)


Any Ideas ?

Thanks
9年前 に Vishal Patel によって更新されました。

RE: ServiceContext in JSF Spring Portlet

Junior Member 投稿: 83 参加年月日: 14/11/24 最新の投稿
Hi,

Your code is trying to get ROLE "Community Content Reviewer" which is yet not created in Liferay.

So please create one role in Liferay name "Community Content Reviewer" and then try again.