S
stephent
Guest
Hi,
I have been searching for an answer to this for a while and have not found one but if one is out there then please just point me at it.
I am using Grails 2.1.1 and am trying to use the scaffolding for editing something with an embedded object. Even trying the example from this page fails: http://grails.org/doc/latest/ref/Domain Classes/embedded.html
This is the code for the model, which looks reasonable:
And that creates a Person table which includes the four columns for the two properties of the two Country objects.
I have a controller like this:
And when I access the person/create page, I get this error:
Is the default scaffolding just not able to handle the embedded case or have I done something wrong? If I need to write a custom gsp then I will do so, but it just seemed that I must be doing something wrong for this not to work.
Thanks
I have been searching for an answer to this for a while and have not found one but if one is out there then please just point me at it.
I am using Grails 2.1.1 and am trying to use the scaffolding for editing something with an embedded object. Even trying the example from this page fails: http://grails.org/doc/latest/ref/Domain Classes/embedded.html
This is the code for the model, which looks reasonable:
Code:
class Person {
String name
Country bornInCountry
Country livesInCountry
static embedded = ['bornInCountry', 'livesInCountry']
}
// If you don't want an associated table created for this class, either
// define it in the same file as Person or put Country.groovy under the
// src/groovy directory.
class Country {
String iso3
String name
}
And that creates a Person table which includes the four columns for the two properties of the two Country objects.
I have a controller like this:
Code:
class PersonController {
def scaffold = Person
}
And when I access the person/create page, I get this error:
Code:
Line | Method
->> 464 | runTask in /person/create
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by GrailsTagException: Error executing tag <g:form>: Error executing tag <g:render>: Error evaluating expression [countryInstance.id] on line [10]: Cannot get property 'id' on null object
->> 36 | doCall in /person/create
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by GrailsTagException: Error executing tag <g:render>: Error evaluating expression [countryInstance.id] on line [10]: Cannot get property 'id' on null object
->> 31 | doCall in /person/create
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by GroovyPagesException: Error evaluating expression [countryInstance.id] on line [10]: Cannot get property 'id' on null object
->> 10 | run in /person/_form.gsp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by NullPointerException: Cannot get property 'id' on null object
->> 10 | doCall in person__form_gsp$_run_closure8
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 31 | doCall in person_create$_run_closure2_closure24
| 36 | doCall in person_create$_run_closure2
| 38 | run in person_create
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run in ''
^ 662 | run . . in java.lang.Thread
Is the default scaffolding just not able to handle the embedded case or have I done something wrong? If I need to write a custom gsp then I will do so, but it just seemed that I must be doing something wrong for this not to work.
Thanks