Code example for ModelAndView

Methods: addObjectsetViewName

0
 
        /* 
         *  Add groups and people matching the search query to the JSON model 
         */ 
         
        ModelAndView mv = new ModelAndView();
        List<JsonEntityBean> groups = new ArrayList<JsonEntityBean>();
        groups.addAll(listHelper.search(EntityEnum.GROUP.toString(), query));
        Collections.sort(groups);
        mv.addObject("groups", groups);
 
        List<JsonEntityBean> people = new ArrayList<JsonEntityBean>();
        people.addAll(listHelper.search(EntityEnum.PERSON.toString(), query));
        Collections.sort(people);
        mv.addObject("people", people);
        mv.setViewName("json");
         
        return mv;
    } 
 
}