Grails: Where is [domainClassName]instance defined and how is it use? -


i'm new in grails , trying understand existing code.

i focused on 1 module first, name of domain class employee , try understand crud. found lots of employeeinstance?.userlastmodified of , wondering how employeeinstance defined. automatic if create employee domain class, have employeeinstance? how work , question mark for?

thank you.

you've seen employeeinstance in gsp or in controller. defined in controller method. may see controller this:

class employeecontroller {      def show(long id) {         def employee = employee.get(id)          [employeeinstance: employee]     }  } 

and corresponding gsp page named grails-app/employee/show.gsp uses employeeinstance.

with groovy null-safe operator can code this:

def date = employeeinstance?.userlastmodified 

instead of this:

def date = null if(employeeinstance != null) date = employeeinstance?.userlastmodified 

because if employeeinstance null, date variable set null.

i hope you're reading grails documentation , coding along it. docs near excellent. got quite far in learning grails using documentation.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -