tags:

views:

65

answers:

1

Hello,
I have a gsp template, where the data for create view is passed through the controller.

def create = {
    def bookInstance = new Book()
bookInstance .properties = params
def map = getDefaultValues()
render(template: "create", model: [bookInstance : bookInstance ,
            title: map.title,
            somelist: somelist
            ....])

the gsp template

 <g:select optionKey="id" from="${somelist}" name="somelist.id" value="${bookInstance ?.somelist?.id}" noSelection="['null': '']"></g:select>

now, in the save method, if there is an error, it returns currently populated and validated instance (default scaffold implementation)

render(template: "create", model: [bookInstance : bookInstance ])

But the fields in the gsp (error page rendered from save action) is empty. I could see the reason as it looks the value in "${somelist}" , but it is not used in save method. Do i just need to check for null in the gsp and use whichever map is available, or any better method (passing all the map in the save method is not an option) ..
thanks in advance..

A: 

I figured it out.. I have to pass the same map as was in the create closure .. the reason why we were passing the maps in create is because we wanted to override the default list.. the populated values in bookInstance is only used to preserve the user selection, but not all the values..

bsreekanth