Forums de discussion

how to retreive list of calendar events from CalendarBooking

jam dah, modifié il y a 9 années.

how to retreive list of calendar events from CalendarBooking

Junior Member Publications: 43 Date d'inscription: 13/08/14 Publications récentes
Hi,
I am newer on liferay,I am using liferay 6.2-ga2.
I need to retreive list of calendar events from CalendarBooking, need your helps.
i added the calender service jar to my classpath, i found this code in the liferay forums, but it didn't work for me.
 DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(CalendarBooking.class, classLoader);
		 Conjunction primaryCriteria = RestrictionsFactoryUtil.conjunction();
		 //primaryCriteria.add(PropertyFactoryUtil.forName("startDate").le(todayDate));
		 dynamicQuery.add(primaryCriteria);
		 dynamicQuery.addOrder(OrderFactoryUtil.desc("startDate"));
		 dynamicQuery.setLimit(0, 20);
		 return (List<calendarbooking>) CalendarBookingLocalServiceUtil.dynamicQuery(dynamicQuery);</calendarbooking>

Thanks
thumbnail
Manali Lalaji, modifié il y a 9 années.

RE: how to retreive list of calendar events from CalendarBooking

Expert Publications: 362 Date d'inscription: 09/03/10 Publications récentes
Hi,

Are you creating your own custom Entity? Can you try below code?


public List<calendareventmodel> getEvents() throws SystemException, PortalException {

final List<calendarbooking> calEventsList = getAllCalendarBookingEvent();
  for (CalendarBooking calendarBooking : calEventsList) {
   //
  }
}

</calendarbooking></calendareventmodel>


In getAllCalendarBookingEvent() method, can you try adding accessing CalendarBookingLocalServiceUtil.getCalendarBookings(0,0) and get eventIds for the same.



HTH!
jam dah, modifié il y a 9 années.

RE: how to retreive list of calendar events from CalendarBooking

Junior Member Publications: 43 Date d'inscription: 13/08/14 Publications récentes
Thanks for your help,
but it showed me two errors
The method getAllCalendarBookingEvent() is undefined for the type 

The method getCalendarEventModel(CalendarBooking) is undefined for the type 

Thanks
thumbnail
Manali Lalaji, modifié il y a 9 années.

RE: how to retreive list of calendar events from CalendarBooking (Réponse)

Expert Publications: 362 Date d'inscription: 09/03/10 Publications récentes
jam dah:
Thanks for your help,
but it showed me two errors
The method getAllCalendarBookingEvent() is undefined for the type 

The method getCalendarEventModel(CalendarBooking) is undefined for the type 

Thanks


Hi,

You can also try to retrive using DynamicQuery for CalendarBooking class:


 DynamicQuery query = DynamicQueryFactoryUtil.forClass(CalendarBooking.class, portalClassLoader)
                    .add(PropertyFactoryUtil.forName("startTime").le(endDate.getTime()))            
                     .addOrder(OrderFactoryUtil.desc("startTime"));
                                            
             List&lt; CalendarBooking&gt; events = CalendarBookingLocalServiceUtil.dynamicQuery(query);
             for ( CalendarBooking event : events) 
             {
                 ...
            }   



Refer: link , link1

HTH!