-
May 1st, 2012, 11:29 AM
#1
Changing the way the ITDs are generated
I am working on a project with Roo and JSON. Is it possible to change the output of the generated ITDs for the controllers? For example, if I want to change the content of the RequestMapping from:
@RequestMapping(value = "/jsonArray", method = RequestMethod.PUT, headers = "Accept=application/json")
To
@RequestMapping(value = "/somethingElse", method = RequestMethod.PUT, headers = "Accept=application/json")
Or another example would be that when I update an Entity via a JSON submission, how can I customize the return value to be the updated entity rather than just a status code? Essentially I want to Roo to produce this for an update in my controller:
@RequestMapping(method = RequestMethod.PUT, headers = "Accept=application/json")
@ResponseBody
public ResponseEntity<String> Something.updateFromJson(@RequestBody String json) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
Something someThing = Something.fromJsonToTask(json);
if (task.merge() == null) {
return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<String>( someThing.toJson(), HttpStatus.OK);
}
Specifically, I'd like to know how I can change the way the *_Roo_Controller_Json.aj is rendered.
I know I can use the push-in feature of Roo but this would be time consuming to every time I add a controller, it would be preferable to change the generated code so that Roo is creating the ITD methods exactly as I need them.
Thanks in advance for any suggestions!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules