Foren

get calendar class loader in liferay 7

juan meza, geändert vor 7 Jahren.

get calendar class loader in liferay 7

Regular Member Beiträge: 228 Beitrittsdatum: 06.01.14 Neueste Beiträge
hi, im trying to migrate a portlet from liferay 6.2 to liferay 7... in this portlet i use the calendar a lot (to add and read events)

i used to get the calendar class loader like this:
String servletContextName = "calendar-portlet";
ClassLoader classLoader = (ClassLoader)com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(servletContextName, "portletClassLoader");


but this does not work in lifeary 7... because of the modules i guess... how can i get the class loader in liferay 7?
thumbnail
David H Nebinger, geändert vor 7 Jahren.

RE: get calendar class loader in liferay 7

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
um, rarely do you really need another modules class loader? Perhaps you don't need it at all? Not sure w/o further details.







Come meet me at the 2017 LSNA!
juan meza, geändert vor 7 Jahren.

RE: get calendar class loader in liferay 7

Regular Member Beiträge: 228 Beitrittsdatum: 06.01.14 Neueste Beiträge
Hi David, thank you... what i want is to get all calendars by groupId... i mean the calendars from the calendar portlet

String servletContextName = "calendar-portlet";
ClassLoader classLoader = (ClassLoader)com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(servletContextName, "portletClassLoader");

// find calendarID via GroupID
// com/liferay/calendar/service/CalendarLocalServiceUtil
com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery = com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil.forClass(com.liferay.calendar.model.Calendar.class, classLoader);
dynamicQuery.add(com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil.forName("groupId").eq(groupId));
java.util.List<com.liferay.calendar.model.calendar> calendars = com.liferay.calendar.service.CalendarLocalServiceUtil.dynamicQuery(dynamicQuery);</com.liferay.calendar.model.calendar>


but when i try to do it i get this exception:
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator is not set for servlet context calendar-portlet
at com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(PortletBeanLocatorUtil.java:46)
at birthdays.portlet.BirthdaysPortlet.getCalendars(BirthdaysPortlet.java:225)


so how do i get the calendars in my site?

thank you!
thumbnail
David H Nebinger, geändert vor 7 Jahren.

RE: get calendar class loader in liferay 7 (Antwort)

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Just use the CalendarLocalServiceUtil.dynamicQuery() method (w/ no params) and you'll get a DQ instance ready for adding your stuff.






Come meet me at the 2017 LSNA!
juan meza, geändert vor 7 Jahren.

RE: get calendar class loader in liferay 7

Regular Member Beiträge: 228 Beitrittsdatum: 06.01.14 Neueste Beiträge
it works that way! thank you!