O'Reilly logo

Grails 2: A Quick-Start Guide by Ben Klein, Dave Klein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Anatomy of a Grails Controller

Let’s examine the TekEventController first: what is it doing for us, and what else we can do with it? Open TekDays/grails-app/controllers/com/tekdays/TekEventController.groovy, and follow along as we take a look at it in chunks:

beyond.2/TekDays/grails-app/controllers/com/tekdays/TekEventController.groovy
 
package​ com.tekdays
 
 
import​ static org.springframework.http.HttpStatus.*
 
import​ grails.transaction.Transactional
 
 
@Transactional(readOnly = true)
 
class​ TekEventController {
 
 
static​ allowedMethods = [save: ​"POST"​, update: ​"PUT"​, delete: ​"DELETE"​]
 
 
def​ index(​Integer​ max) {
 
params.max = ​Math​.min(max ?: 10, 100)
 
respond TekEvent.list(params),
 
model:[tekEventInstanceCount: TekEvent.count()] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required