Grails rejected value, type mismatch -


i don't know what's wrong code, value right when save it, errors

grails.validation.validationexception: validation error(s) occured during save(): - field error in object 'specialrate' on field 'fromcurrency': rejected value [idr - indonesian rupiah]; codes [typemismatch.specialrate.fromcurrency, ......  grails.validation.validationexception: validation error(s) occured during save(): - field error in object 'specialrate' on field 'validthru': rejected value [mon jul 15 00:00:00 ict 2013]; codes [typemismatch.specialrate.fromcurrency, ...... not parse date: unparsable date: "15/07/2013"] 

here domain class

import java.util.date; import currency;      class specialrate {          static auditable = true              string bookingcode         currency fromcurrency         date validthru          static constraints = {         bookingcode(blank: false, maxsize :20)             fromcurrency(blank:true, nullable: true)             validthru(blank: true, nullable: true)               }     } 

here's save controller:

def save = {             def specialrateinstance = new specialrate()         specialrateinstance.properties = params         simpledateformat formatter = new simpledateformat("dd/mm/yyyy")         specialrateinstance.validthru = formatter.parse(params.validthru)          def fromcurrency = currency.get(params.fromcurrency);         specialrateinstance.fromcurrency = fromcurrency           withformat {             html {                 withform {                     try {                         specialrateinstance = specialrateservice.save(specialrateinstance)                     }                     catch (grails.validation.validationexception e) {                         logger.error("missing property or validation fails", e)                     }                     catch (runtimeexception e) {                         logger.error(e.getmessage(), e)                         redirect(controller: "error", action: "servererror")                         return                     }                      if (!specialrateinstance.haserrors()) {                         flash.message = "${message(code: 'default.created.message', args: [message(code: 'specialrate.label', default: 'specialrate'), specialrateinstance.bookingcode])}"                         redirect(action: "show", id: specialrateinstance.id)                     }                     else {                         render(view: "create", model: [specialrateinstance: specialrateinstance ])                     }                 }.invalidtoken {                     redirect(controller: "error", action: "forbidden")                 }             }         }     } 

and service :

def save (def specialrateinstance){         specialrateinstance.save(failonerror: true)         return specialrateinstance     } 

anyone can me , found mistake, code error results? :)

  • fromcurrency of type currency setting string value params.
  • validthru unparseable because format mon jul 15 00:00:00 ict 2013 , expecting dd/mm/yyyy.

steps recover:-

  • follow @james kleeh.
  • verify fromcurrency of type currency once set.
  • match date format validthru. make sure validthru set in params dd/mm/yyyy.

Comments