Grails: can remoteField update multiple fields?

Posted by Michael Bavin on Stack Overflow See other posts from Stack Overflow or by Michael Bavin
Published on 2010-05-06T11:17:20Z Indexed on 2010/05/10 6:04 UTC
Read the original article Hit count: 191

Filed under:
|
|

Hi,

Assume i have a book entity with an isbn field. When entered a isbn number, i want 2 fields to be updated: title and author.

My controller looks like this:

def ajaxGetBook = {
        def book = Book.findByIsbn(params.isbn)
        if(book==null) book = new Book()
        render book as JSON
    }

So my call works, and i get a full JSON Book. Now i would like to update 2 texfields by the update attribute

 <g:remoteField action="ajaxGetBook" update="title"  name="isbn" value="${bookInstance?.book?.isbn}" paramName="isbn"/>

Now the title field gets updated with the full book object, so that doesn't work.

Is it possible to update field title with only the JSON book.title?

Is it possible to update more fields at once?

I could render book.title as JSON but that works for only one field.

Thank you

© Stack Overflow or respective owner

Related posts about grails

Related posts about groovy