views:

190

answers:

1

Hi,

I'm using g:datePicker name="date1" id="date1" value="${program?.startDate}" >

In controller when used params.date1 it is showing value as "struct" and unable to save date in my database.

How can we parse date in to one param like eg: 2010-10-10 11:11:11 using datePicker ?

thanks in advance
srinath

A: 

You'll want to look into Data binding in Grails. Data binding happens automatically with domain objects when you say Book b = new Book(params) or if you use a Command Object.

def myAction = { BookCommand bookCommand -> 
    //bookCommand is already bound and validated by now
}

You can also manually invoke bindData(...) in your controller (documentation) if you want to. Most likely you'll just want to use bindData like this:

def myAction = {
    ...
    bindData(myDomainObject, params, ['date1'])
    ...
    myDomainObject.save()
    ...
}
Colin Harrington
thanks Colin for giving answer
Srinath