0
votes

I am trying to load events to full calendar via a controller

Here is my script on the jsp :


 $(document).ready(function () {
     var calendar = $('#calendar').fullCalendar({
         editable: true,
         eventSources: [{
         // your event source
             url: 'calendarDetails',
             type: 'GET',
             data: {
                 start: 'start',
                 id: 'id',
                 title: 'title,'
             },
             error: function () {
                 alert('there was an error while fetching events!');
             },
             color: 'yellow',
             textColor: 'black'
         }])
     };)
 };

and inside my controller:

@RequestMapping(value="/calendarDetails",  method=RequestMethod.GET) 
public  @ResponseBody void showCalendarDetails(HttpServletResponse response){

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 111);
    map.put("title", "event1");
    map.put("start", "2011-07-28");
    map.put("url", "http://yahoo.com/");

    // Convert to JSON string.
    String json = new Gson().toJson(map);
    logger.info(json);

    // Write JSON string.
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    try {
        response.getWriter().write(json);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

The request and response are showing an ok status and I can see the response being sent back as a json in the firebug as {"id":111,"title":"event1","start":"2011-07-28","url":"http://yahoo.com/"}

However the full calendar will not show the event loaded. Am I missing something?

Thanks in advance for your help.

1

1 Answers

1
votes

Have you tried to remove the comma from title: 'title,'?