Monday, October 26, 2009

Grails scaffolding for domain classes in packages

While working on one simple subproject for spend day with kids I got one interesting issue. I don't use scaffolding too often but this time I needed to get proof of concept. And I came to something where I am not sure if it is a bug or feature. And just to be clear this is happening with Grails version 1.0.3 and I am not sure if it is reproducible in later versions.

Note: Having packages for domain classes is highly advisable and you should always use packages for all domain classes.
So let get to the point. I have create following domain class (please notice that package is defined).

com.jan.rssbuilder.domain.RssChannel
And after that I have created RssChannelController this way:
package com.jan.rssbuilder.domain

class RssChannelController {
def scaffold = true
}
After accessing this controller I got following exception:
java.lang.IllegalStateException: Scaffolder supports action [index] for controller [com.jan.rssbuilder.domain.RssChannelController] but getAction returned null!
After changing controller by specifying domain class everything worked fine:
package com.jan.rssbuilder.domain

class RssChannelController {
def scaffold = com.jan.rssbuilder.domain.RssChannel
}

No comments: