List of usage examples for com.liferay.portal.kernel.bean PortletBeanLocatorUtil getBeanLocator
public static BeanLocator getBeanLocator(String servletContextName)
From source file:au.com.permeance.liferay.portlet.controller.SamplePortletController.java
License:Open Source License
@RenderMapping public String handleViewPage(final RenderRequest request, final ModelMap model) throws SystemException { _log.info("In View"); BeanLocator bl = PortletBeanLocatorUtil.getBeanLocator("calendar-portlet"); FluentReflectionInvokation calendarSvc = FluentReflection.within(bl) .on("com.liferay.calendar.service.CalendarLocalService"); FluentReflectionInvokation bookingsSvc = FluentReflection.within(bl) .on("com.liferay.calendar.service.CalendarBookingLocalService"); Object result = calendarSvc.invoke("getCalendarsCount"); List<?> calendars = (List<?>) calendarSvc.invoke("getCalendars", 0, 100); Map<Object, Object> calIdToBookings = new HashMap<Object, Object>(); for (Object cal : calendars) { FluentReflectionInvokation calendar = FluentReflection.on(cal); Object calendarId = calendar.invoke("getCalendarId"); List<BookingVO> bookingVos = new LinkedList<SamplePortletController.BookingVO>(); List<?> bookings = (List<?>) bookingsSvc.invoke("getCalendarBookings", calendarId); for (Object bookingObj : bookings) { FluentReflectionInvokation booking = FluentReflection.on(bookingObj); String title = (String) booking.invoke("getTitle", "en-US"); long startDate = (Long) booking.invoke("getStartTime"); long endDate = (Long) booking.invoke("getEndTime"); BookingVO vo = new BookingVO(); vo.title = title;/* w w w .j a v a 2s.c om*/ vo.start = new Date(startDate); vo.end = new Date(endDate); bookingVos.add(vo); } calIdToBookings.put(calendarId, bookingVos); } String[] names; if (bl != null) { names = bl.getNames(); } else { names = new String[] { "not found" }; } model.put("calendarsCount", result); model.put("calendars", calendars); model.put("beanNames", names); model.put("bookings", calIdToBookings); return "view"; }