ok, so I spotted where it was going wrong and have a work around.
Say my entity and controller were created as Venue and VenueController. Looking in the generated VenueController_Roo_Controller.aj I could see that there was a list() mehod and a matching listJson() method. But looking at the finder there was the findBy() type of method but no corresponding findByJson(() method.
To get around this I added the relevant findByJson() method directly to my controller.
So, for example, my VenueController_Roo_Controller.aj contained the following generated finder method:
Code:
@RequestMapping(params = "find=ByNameLike", method = RequestMethod.GET)
public String VenueController.findVenuesByNameLike(@RequestParam("name") String name, Model model) {
model.addAttribute("venues", Venue.findVenuesByNameLike(name).getResultList());
return "venues/list";
}
To make the above json aware I added the following method directly to my VenueController:
Code:
@RequestMapping(headers = "Accept=application/json", params = "find=ByNameLike", method = RequestMethod.GET)
@ResponseBody
public String findVenuesByNameLikeJson(@RequestParam("name") String name) {
@SuppressWarnings("unchecked")
Collection<Venue> venues = (Collection<Venue>) Venue.findVenuesByNameLike(name).getResultList();
return Venue.toJsonArray(venues);
}