我有這樣的命令對象:Grails的命令對象的驗證使例外,而不是錯誤
@Validateable
class TaCustomerBoardActionCommand {
TaCustomerBoardAction action
static constraints = {
action casecade: true
}
}
,並在下面的命令對象類:
class TaCustomerBoardAction {
TaCustomerBoard taCustomerBoard
TaapAction taapAction
Date dateCreated // updated by grails
Date lastUpdated // updated by grails
User createdBy
OrgUnit orgUnit
Client client
static belongsTo = [Client]
static constraints = {
}
}
和
TaapAction {
int id
User createdUser
User responsibleUser
Brand brand
BusinessType businessType
Topic topic
Topic subTopic
String subject
String description
Date targetDate
int progress
String responsible
Client client
static belongsTo = [Client]
OrgUnit orgUnit
Date dateCreated // updated by grails
Date lastUpdated // updated by grails
TaapActionState taapActionState
static constraints = {
subject nullable: false, size: 1..64
description nullable: false, size: 1..4000
responsible nullable: false, size: 1..512
progress nullable: false
responsibleUser nullable:false
brand nullable:false
businessType nullable:false
topic nullable:false
subTopic nullable:false
targetDate nullable:false
}
TaCustomerBoard有與上述類似的約束。 但它給出異常而不是錯誤代碼。 下面是控制器Post方法:
def saveTaCustomerBoardAction(TaCustomerBoardActionCommand cmd){
if(cmd.validate()){
taActionPlanningService.saveAction(cmd.action.taapAction)
cmd.action.save(flush: true, failOnError: true)
}
[cmd:cmd]
}
堆棧跟蹤:
grails.validation.ValidationException:驗證錯誤(S)保存()過程中發生 : - 在對象「去字段錯誤。 idare.move.taap.TaapAction'on field'progress':rejected value [null];代碼 [de.idare.move.taap.TaapAction.progress.typeMismatch.error,de.idare.move.taap.TaapAction.progress.typeMismatch,taapAction.progress.typeMismatch.error,taapAction.progress.typeMismatch,typeMismatch.de .idare.move.taap.TaapAction.progress,typeMismatch.progress,typeMismatch.int,typeMismatch]; 爭論[progress];默認消息[數據綁定失敗] - 字段'description'的對象'de.idare.move.taap.TaapAction'中的字段錯誤:rejected value [null];代碼 [de.idare.move.taap.TaapAction.description.nullable.error.de.idare.move.taap.TaapAction.description,de.idare.move.taap.TaapAction.description.nullable.error.description,de .idare.move.taap.TaapAction.description.nullable.error.java.lang.String,de.idare.move.taap.TaapAction.description.nullable.error,taapAction.description.nullable.error.de.idare.move .taap.TaapAction.description,taapAction.description.nullable.error.description,taapAction.description.nullable.error.java.lang.String,taapAction.description.nullable.error,de.idare.move.taap.TaapAction.description .nullable.de.idare.move.taap.TaapAction.description,de.idare.move.taap.TaapAction.description.nullable.description,de.idare.move.taap.TaapAction.description.nullable.java.lang.String ,de.idare.move.taap.TaapAction.description.nullable,taapAction.description.nullable.de.idare.move.taap.TaapAction.description,taapAction.description.nullable.description,taapAction.description.nullable.java.lang .Stri納克,taapAction.description.nullable,nullable.de.idare.move.taap.TaapAction.description,nullable.description,nullable.java.lang.String,可爲空]。 arguments [description,class de.idare.move.taap.TaapAction];默認 消息[類[{1}]的屬性[{0}]不能爲空]
請幫我解決這個問題。
您正在使用哪個版本的Grails? –