I've got two domain classes: Car and Driver. I'd like to make a gsp view that displays the Car and Driver info in a list that looks more or less a default scaffolded list. For example:
Make Model Driver Age
------------------------
Chevy Nova Joe 20
Chevy Nova Mike 30
Chevy Nova Sally 40
Here's the domain classes:
class Car {
String make
String model
static constraints = { }
static hasMany = [ drivers : Driver ]
static mapping = {
drivers joinTable: [name: 'Car_Driver', column: 'DRIVER_ID', key: 'CAR_ID']
}
}
class Driver {
String name
int age
static constraints = { }
}
Make a car and give it a few drivers:
def car = new Car(make: 'Chevy', model: 'Nova')
def driver1 = new Driver(name: 'Joe', age: 20)
def driver2 = new Driver(name: 'Mike', age: 30)
def driver3 = new Driver(name: 'Sally', age: 40)
car.addToDrivers(driver1)
car.addToDrivers(driver2)
car.addToDrivers(driver3)
car.save()
What do I need to do in my CarController and/or gsp view to make a joined list happen (and still work with pagination)?