Announcement Announcement Module
Collapse
No announcement yet.
Roo way of replacing show method on scaffolded controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo way of replacing show method on scaffolded controller

    Hi,

    I'm using roo 1.2.2

    I have created a controller annotated with @RooWebScaffold(path = "cards", formBackingObject = Card.class), so I get methods like show, update, create etc generated

    However, I which to customize

    Code:
    public String show(@PathVariable("id") Long id, Model uiModel) {
    ..
    on the controller.

    I simply did that by adding this method to my controller and removing

    Code:
        @RequestMapping(value = "/{id}", produces = "text/html")
        public String CardController.show(@PathVariable("id") Long id, Model uiModel) {
            uiModel.addAttribute("card", Card.findCard(id));
            uiModel.addAttribute("itemId", id);
            return "cards/show";
        }
    from the backing aj file, in this case CardController_Roo_Controller which seems to work.

    If I would remove the create method, I could have done it using the annotation on the controller, like

    Code:
    @RooWebScaffold(path = "cards", formBackingObject = Card.class,create=false)
    So is the above the correct way to create a custom version of the show method.

    Best Regards
    Niels

  • #2
    Hi!

    There are two different questions here.

    So, in order to edit the "show" method, you indeed have to copy (or create a new one with the same name) on the controller java file. Beware to adjust the aspect-specific syntax, in this case remove "CardController" from "CardController.show".

    Secondly, if you want to remove the "create" method, then yes, specifying "create=false" is the correct way to do it.

    Best,
    Radu

    Comment

    Working...
    X