2

I am using grails and i have a basic form remote

<g:formRemote name="add" onSuccess="close();" onFailure="dispayErrors();\"
                  url="[controller: ctx, action: 'insert']" method="POST" class="add">
 //Some inputs + submit button
</g:formRemote>

My question is what shoud the insert method return for so that onFailure is triggered? Thanx

Dónal
  • 185,044
  • 174
  • 569
  • 824

1 Answers1

2

Change the controller action (temporarily I presume) to

def insert = {
    render status: HttpServletResponse.SC_INTERNAL_SERVER_ERROR

    // This also works
    //response.sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR
}

If you're using Grails 2.0 it is recommended to define your action as a method rather than a closure:

def insert() {
    render status: HttpServletResponse.SC_INTERNAL_SERVER_ERROR
}
Dónal
  • 185,044
  • 174
  • 569
  • 824
  • I didn't know methods were the preferred way of implementing actions in 2.0. For further reading: http://grails.org/doc/latest/guide/theWebLayer.html#understandingControllersAndActions – Jarred Olson Feb 20 '12 at 15:45