Forums de discussion

Freemarker : getEvent API

Sourabh Lonikar, modifié il y a 6 années.

Freemarker : getEvent API

Junior Member Publications: 42 Date d'inscription: 14/11/16 Publications récentes
Hi All,
I am trying to retrieve event using CalEventLocalService API. I am using below code but getting error:

Code : <#assign calEventLocalService= serviceLocator.findService("com.liferay.portlet.calendar.service.CalEventLocalService") />
<#assign calEvent1 = calEventLocalService.getEvent(curEntry.classPK) />

Freemarker Error:
Error on line 44, column 5 in 10155#10195#169551
calEventLocalService.getEvent(curEntry.classPK) is undefined.
It cannot be assigned to calEvent1

How should i get event using API ?

Regards,
Sourabh
thumbnail
Andrew Jardine, modifié il y a 6 années.

RE: Freemarker : getEvent API

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Hi Sourabh ,

The calendar API is part of a portlet, not the core product so when you are using the Service Locator, you need to use the method with two arguments .. one for the service and the second that specified the servlet context where the service can be found.

public Object findService(String servletContextName, String serviceName)


The way I see your code right now, you are trying to get a handle on the service but it can't find it. So your service reference is likely a null.