Announcement Announcement Module
No announcement yet.
overriding controller method breaks Roo Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • overriding controller method breaks Roo

    I have the web scaffolding for an entity generated by roo. In the controller, I pushed in exactly one method

    @RooWebScaffold(path = "thermalspaces", formBackingObject = ThermalSpace.class)
    public class ThermalSpaceController {
        @RequestMapping(value = "/{id}", method = RequestMethod.GET)
        public String show(@PathVariable("id") Long id, Model uiModel) {
            uiModel.addAttribute("thermalspace", ThermalSpace.findThermalSpace(id));
            uiModel.addAttribute("itemId", id);
            return "thermalspaces/show";
    Note that the method in question is unchanged from the version generated by roo in the _Roo_Controller.aj aspect. I just added it to the java file and modified the declaration so that it was legal syntax for a java method.

    I was getting the following warnings (or, at least, I took them to be warnings) when the roo shell initialized

    Undo manage SRC_MAIN_WEBAPP/WEB-INF/i18n/
    Method 'show' already defined in target type '' (ITD target '')
    I assumed that was just the roo shell telling me that it had found my version of the method so it was not generating the same thing in the aspect - and, indeed, the method was not generated. However, it was apparently preventing the shell from doing any further work when scanning the filesystem for changes - so roo completely stopped generating aspects for any of my domain entities - which were apparently processed after the web controller. And changes made to a domain entity were not reflected in the aspects generated by roo, so I could not modify toString methods, update the @RooEntity annotation, or even generate new entities via the roo shell. As soon as I commented out the controller method in the java file and re-launched the roo shell, the shell detected all of my changes and proceeded to re-generate everything as I had been expecting it to do.

    So my question is - if I need to modify a web scaffold controller method so that I can add something else to the model, how can I do so without breaking my entire roo project?

  • #2
    Note: the roo documentation has this to say about controller methods:

    "As you can see Roo implements a number of methods to offer a RESTful MVC frontend to your domain layer. All of these methods can be found in the PersonController_Roo_Controller.aj ITD. Feel free to push-in any (or all) of these methods to change default behaviour implemented by Roo."

    So I'm going to go over and report this as a bug.


    • #3
      This was resolved in ROO-2368