Adding custom methods to your hook environment?

I am adding a new method to CalEventLocalServiceImpl using hook ...

my code ...

 public class MyCalendarLocalServiceImpl extends CalEventLocalServiceWrapper { public MyCalendarLocalServiceImpl(CalEventLocalService calEventLocalService) { super(calEventLocalService); // TODO Auto-generated constructor stub } public List getUserData(long userId) throws SystemException{ DynamicQuery query=DynamicQueryFactoryUtil.forClass(CalEvent.class) .add(PropertyFactoryUtil.forName("userId").eq(userId)); List deatils=CalEventLocalServiceUtil.dynamicQuery(query); return deatils; } } 

liferay-hook.xml :

 <service> <service-type> com.liferay.portlet.calendar.service.CalEventLocalService </service-type> <service-impl> com.liferay.portlet.calendar.service.impl.MyCalendarLocalServiceImpl </service-impl> </service> 

My question is how to use getUserData strong> from jsp file. Can anyone help me ...

I think I didn’t have my question ... I want a list of events based on the USERID from the Calendar ... to achieve this, what should I do?

+2
source share
2 answers

I assume that getUserData () is not overridden, but a new method (currently it cannot be viewed). This is not something you can do when overriding a service. Instead, you will have to add a new service and make it available to the portal.

Remember that custom (“connected”) jsp is running in the portal classloader, and your overloaded service is running in the hookloader. Thus, if you create a new service and provide service.jar for Liferay (for example, in the global classpath), you can call it from the JSP. The Liferay Services interface cannot be extended through an overloaded service.

In case getUserData () is already in the interface (as I said, I can’t look at the moment), you just need to call CalendarLocalServiceUtil from jsp and it will be delegated to your shell.

+4
source

Just add Olaf's answer and comments ...

if you want to expand the CalEventLocalService service only with "getUsetData" and use it in one jsp, than creating your own service may be unnecessary. Just enter the code from "getUserData" in jsp. Otherwise, follow Olaf's recommendations.

+3
source

All Articles