I have a requirement where on ajax call i need to populate the table. I am using jquery ajax and spring mvc. Below is the code i am using to populate the bean using modelattribute, but when i go to the jsp modelattribute is not available at all. Any help would be really appreciable.
@RequestMapping(value = "/getFullSchedule", method = RequestMethod.GET, produces="application/json")
public @ResponseBody ScheduleBean displayFullSchedule(@ModelAttribute("scheduleBean") ScheduleBean scheduleBean,
@RequestParam(value= "callCenterId", required=true, defaultValue = "-1") String callCenterId,
@RequestParam(value= "queueId", required=true, defaultValue = "-1") String queueId, Model model)
throws ServiceException {
logger.debug("Getting full schedule for callCenterId(" + callCenterId + ") and queueId(" + queueId + ")");
QueueScheduleFull fullSchedule = scheduleService.get7DaySchedule(callCenterId, queueId);
logger.debug(fullSchedule);
// ScheduleBean scheduleBean = new ScheduleBean();
scheduleBean.setCallCenterId(fullSchedule.getCallCenterId());
scheduleBean.setQueueId(fullSchedule.getQueueId());
scheduleBean.setVdnDesc(fullSchedule.getVdnDesc());
Collection<DaySchedule> days = new ArrayList<DaySchedule>();
days.add(fullSchedule.getWeeklySchedule().getMonday());
days.add(fullSchedule.getWeeklySchedule().getTuesday());
days.add(fullSchedule.getWeeklySchedule().getWednesday());
days.add(fullSchedule.getWeeklySchedule().getThursday());
days.add(fullSchedule.getWeeklySchedule().getFriday());
days.add(fullSchedule.getWeeklySchedule().getSaturday());
days.add(fullSchedule.getWeeklySchedule().getSunday());
scheduleBean.setDays(days);
model.addAttribute("scheduleBean", scheduleBean);
model.addAttribute("chetan", "test");
return scheduleBean;
}
And the jsp part looks like below
<c:out value="HELLO${chetan}"></c:out>
<c:out value="Help me out here${scheduleBean.days[0].startTime}"/>
<display:table htmlId="scheduleTable" name="${scheduleBean.days}" pagesize="15"
export="false" sort="list" cellpadding="0" cellspacing="0"
width="100%" requestURI="" id="fullScheduleTable" align="left" class="pure-table pure-table-bordered">
<display:column title = "abc">
<div>${fullScheduleTable.startTime}</div>
</display:column>
</display:table>
Nothing in the model or ModelAttribute is available on the jsp page.
I have also added the jackson mapper in the dispatcher-servlet and still no go.
<mvc:annotation-driven />
<bean id="jacksonMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />