Can a grails controller extend from a base class? How to make it so grails doesn't blow up?
Posted
by egervari
on Stack Overflow
See other posts from Stack Overflow
or by egervari
Published on 2010-05-29T23:25:01Z
Indexed on
2010/05/29
23:32 UTC
Read the original article
Hit count: 342
I wrote a base class to help build my controllers more quickly and to remove duplication. It provides some helper methods, default actions and some meta programming to make these things easier to build.
One of those methods in the base class is like this:
def dynamicList(Class clazz) {
def model = new LinkedHashMap()
model[getMapString(clazz) + "s"] = list(clazz)
model[getMapString(clazz) + "sTotal"] = count(clazz)
model
}
The action that calls it, also in the base class, is this:
def list = {
dynamicList(clazz)
}
Unfortunately, when I go to list action in the controller subclass that inherits the base class when my application is deployed, I get this exception:
groovy.lang.MissingMethodException: No signature of method: groovy.lang.MissingMethodException.dynamicList() is applicable for argument types: (java.lang.Class) values: [class project
.user.User]
at project.user.UserController$_closure1.doCall(UserController.groovy:18)
at project.user.UserController$_closure1.doCall(UserController.groovy)
at java.lang.Thread.run(Thread.java:619)
How can I hit grails over the head and just tell it do what I want it to do? My controller unit tests run just fine, so grails' run-time is totally at fault :/
Ken
© Stack Overflow or respective owner