Upcoming Events

The Calendar functionality in the CQ5 can be leveraged to build an intuitive portal experiencing for the users. One such experience would be to display the list of upcoming events.

I would provide a simpler approach to achieve the same.

  • Create a new component let’s say upcoming events.

  • Open up the newly created JSP and add the following logical steps
    • Retrieve the Calendar Source in the desired page either by looping through the child pages or parametrize the calendar location as a dialog entry for the component. In our case we shall assume that the dialog entry exists and proceed.
    • if(calendarLocation == null || calendarLocation.equals(""))
      PageFilter filter = new PageFilter(request);
      Iterator iter = currentPage.listChildren(filter);
      Page currPage = iter.next();
      Resource r = currPage.getContentResource("par/calendar");
      if( r != null) {
      calendarManager = currPage.getContentResource().getResourceResolver().adaptTo(CalendarManager.class);
      if(calendarManager != null){
      calendar = calendarManager.getCalendar(currPage.getPath());
      calendarUrl = currPage.getPath()+".html";
      }// resource check
      else {
      calendarManager = currentPage.getContentResource().getResourceResolver().adaptTo(CalendarManager.class);
      if(calendarManager != null){
      calendar = calendarManager.getCalendar(calendarLocation);
      calendarUrl = currentPage.getPath()+".html";
    • Retrieve all the Calendar events using calendar API
    • Iterate over all the events and for each event , read the event properties.
    • If the event happens in future then display the event along with its read properties.
  • Add the component to your webpage using the sidekick after enabling it.
  • The component should resemble like given below once its published or previewed with appropriate data

Share on Facebook