|
I've written the following service based on the link below. It works fine as long as there are no validation errors. If there are, I get a NullPointerException on the highlighted line (the var g is not null). Does anyone see anything obvious that I'm overlooking? I'm running this in the Grails 2.0.0 framework. How can I dig down deeper into this to see whether the problem is with my code or perhaps something in the framework? Any help would be appreciated; thanks. Here's the error information that's written to the console: | Error 2012-01-07 13:38:09,700 ["http-bio-8080"-exec-9] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [POST] /FSIS/issue/save - parameters: severity.id: null dateRequested_month: dateRequested_day: mcmCompleteDate_day: nextSteps: mcmCompleteDate_year: requestor: liaisonContact.id: null moveToLWDate_day: itContact.id: null internalStatus.id: null moveToLWDate_year: dueDate: assignedTo.id: 1 dueDate_month: task: product.id: null mcmCompleteDate: problem: dueDate_year: dateRequested: moveToLWDate: moveToLWDate_month: nursingContact.id: null dateRequested_year: mcmCompleteDate_month: status.id: 5 openedBy.id: 2 dueDate_day: Stacktrace follows: Message: null Line | Method ->> 106 | captureClosureOutput in org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody class JsonService { def grailsApplication def preparePostResponse(domainInstance) { def g = grailsApplication.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib') def postResponse = new AjaxPostResponse(domainObject: domainInstance) if (domainInstance.hasErrors()) { g.eachError(bean: domainInstance) { postResponse.errors."${it.field}" = g.message(error: it) } postResponse.success = false postResponse.message = "There was an error" } else { postResponse.success = true postResponse.message = "Success" } return postResponse } } |
|
Hi,
Looks like a bug in 2.0.0 . Please Jira it. It helps a lot if you could provide a test app and steps to reproduce the problem. Regards, Lari 07.01.2012 21:43, Epps, Aaron wrote: > I've written the following service based on the link below. It works > fine as long as there are no validation errors. If there are, I get a > NullPointerException on the highlighted line (the var g is not null). > Does anyone see anything obvious that I'm overlooking? I'm running > this in the Grails 2.0.0 framework. How can I dig down deeper into > this to see whether the problem is with my code or perhaps something > in the framework? Any help would be appreciated; thanks. > > Here's the error information that's written to the console: > > | Error 2012-01-07 13:38:09,700 ["http-bio-8080"-exec-9] ERROR > errors.GrailsExceptionResolver - NullPointerException occurred when > processing request: [POST] /FSIS/issue/save - parameters: > severity.id: null > dateRequested_month: > dateRequested_day: > mcmCompleteDate_day: > nextSteps: > mcmCompleteDate_year: > requestor: > liaisonContact.id: null > moveToLWDate_day: > itContact.id: null > internalStatus.id: null > moveToLWDate_year: > dueDate: > assignedTo.id: 1 > dueDate_month: > task: > product.id: null > mcmCompleteDate: > problem: > dueDate_year: > dateRequested: > moveToLWDate: > moveToLWDate_month: > nursingContact.id: null > dateRequested_year: > mcmCompleteDate_month: > status.id: 5 > openedBy.id: 2 > dueDate_day: > Stacktrace follows: > Message: null > Line | Method > ->> 106 | captureClosureOutput in > org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody > > http://stackoverflow.com/questions/7718309/grails-jquery-ajax-form-validation > > import org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib > > class JsonService { > > def grailsApplication > > def preparePostResponse(domainInstance) { > def g = > grailsApplication.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib') > def postResponse = new AjaxPostResponse(domainObject: > domainInstance) > if (domainInstance.hasErrors()) { > g.eachError(bean: domainInstance) { > postResponse.errors."${it.field}" = g.message(error: it) > } > postResponse.success = false > postResponse.message = "There was an error" > } else { > postResponse.success = true > postResponse.message = "Success" > } > return postResponse > } > } --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by Epps, Aaron M.
Hi,
I am facing exactly the same problem.. Any solution as yet?? |
|
http://jira.grails.org/browse/GRAILS-8605
Works perfect!. Thanks |
| Powered by Nabble | See how NAML generates this page |
