Alexandru Burghelea
Alexandru Burghelea

Reputation: 166

How can i trigger a onFailure event for g:formRemote?

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

Upvotes: 2

Views: 856

Answers (1)

D&#243;nal
D&#243;nal

Reputation: 187529

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
}

Upvotes: 2

Related Questions