Thursday, July 15, 2010

how to get a domain class instance from a class string (e.g. via params)

I had the problem that I could pass the class name from my gsp to my controller, but I didn't know how to work with that being a String. Luckily I stumpled about the solution in a code example somewhere on the web:

def grailsApplication
grailsApplication.getDomainClass(params.className).newInstance()

No comments:

Post a Comment