I'm using Grails version 2.4.4 and postgresql. When I run app, I see error message Cannot get property 'myname' on null object. I know that table is not empty and database connected correctly, because I can upload and see data using scaffolding.
domain class code:
class My_table {
//Integer id
String myname
static constraints = {}
}
Controller code:
class My_tableController {
def index() {
def my_table = My_table.list()
[my_table:my_table]
}
My index.gsp file:
<g:select name="name" from="${my_table}"/><br/>
<label>${my_table.myname} </label><br/>
Table? Table is a reserved word in ANSI SQL. Are you sure your table even gets created in Postgres? Can you provide the full stacktrace? - saw303500 internal Server Errorwith messageCannot get property 'myname' on null objectand I want to know why - Deividas Kiznismy_tablewould be aListof instances ofMy_tablebut in your GSP you are referring to${my_table.myname}as ifmy_tablewas a particular instance. Is that intentional or are you trying to take advantage of Groovy's special property access on a collection to retrievemynamefrom all of the instances in theList? That doesn't explain whymy_tableisnull, but clearing that up may contribute to further clarity. - Jeff Scott Brown