1

I had an AbstractController in src/groovy/ssh

public void listAjax(){
   //do sth
}

then create-controller system.User

class UserController extends AbstractController{
}

but when I visit /user/listAjax, got 404 error.

parent's public method can't be auto register to sub controller?

atian25
  • 4,166
  • 8
  • 37
  • 60

2 Answers2

1

Are you using Grails 2.0.0M1? Because in Grails 1.3.7 or lower, you can not use methods as controller actions.

If you are using Grails 1.3.7, try this instead for your AbstractController:

public class AbstractController {
    def listAjax = {
       //do sth
    }
}
OverZealous
  • 39,252
  • 15
  • 98
  • 100
  • yes,2.0.0.M1. if parent use closure, how do sub override and call parent closure? super.xx.call()? – atian25 Aug 21 '11 at 05:09
  • With closures, you can't actually use inheritance (I believe), but you could keep the closure in a different property. However, with 2.0 you should be able to use normal method inheritance. If you are still having trouble, try a `grails clean` and run it again. – OverZealous Aug 21 '11 at 06:01
  • Another option would be to use a [Category, as explained here](http://stackoverflow.com/questions/4195492/how-do-you-share-common-methods-in-different-grails-controllers) – OverZealous Aug 21 '11 at 06:02
  • as the link 's comment said :The delegate class doesn't have access to the internals of the owner class, such as the render method or params. – atian25 Aug 21 '11 at 14:23
  • It seems that @mixin, sub controller can't override mixin's method – atian25 Aug 21 '11 at 14:24
0

oh,it's not a bug...

see:

http://jira.grails.org/browse/GRAILS-7938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

https://github.com/grails/grails-doc/commit/3744d8a5d9cad53368aa174d5ac289257b2dfee5

atian25
  • 4,166
  • 8
  • 37
  • 60
  • I have the same problem. I have an abstract base controller under the coontrollers directory, and another controler extending the base one, but base controller methods are not reached with status 404. Any sugestions? – Ben Feb 21 '15 at 01:10