RE: how to use new RegionServiceUtil in 7.4

Scarletake Bwi, modified 3 Years ago. Expert Posts: 327 Join Date: 12/20/10 Recent Posts

hi

i try use 7.4 ce ga15

now i got problem.

i used to call RegionServiceUtil like

RegionServiceUtil.addRegion(countryId, "TW-CHA","TW-CHA", true);

now it's deprecated

i have to switch to 

	public static Region addRegion(
			long countryId, boolean active, String name, double position,
			String regionCode, ServiceContext serviceContext)

can anyone let me know what is position mean, and how to get service context in portlet.

 

thanks in advance.

 

thumbnail
Scarletake Bwi, modified 3 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi ,

If you have request object then you can use

ServiceContext serviceContext = ServiceContextFactory.getInstance(request);

without request object you may use 

ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(PortalUtil.getDefaultCompanyId());
serviceContext.setUserId(_userLocalService.getDefaultUserId());

For Postion value you can set it with 0