我正在尝试使用GRAILS在提交按钮中获取图标。我已经解决了要显示的按钮,但是以抛出错误的形式为代价。为了显示标签我做了一个按钮标签,但随后表单抛出了这个错误:
--> sessionFactory.currentSession.flush() -->AbstractInstanceController.groovy
Cannot insert NULL into ("APP"."INSTANCE"."STATUS")
--> def instance = super.save(specificInstance, 'specificInstance.label') -->specificInstanceController.groovy
gsp中的按钮:
<button type="submit" name="_action_save" class="btn" value="Save">
<i class="icon-folder-open"></i> Save
</button>
有没有人知道如何将图标添加到:
<input type="submit" ...>
或修复使用
抛出的grails错误的方法<button>
方法
更新
<g:form name="form">
<g:hiddenField name="status" />
<g:hiddenField name="locationID" value="${instance?.location?.id}" />
<div class="formButtons">
<g:actionSubmit value="Save" name="save_button" class="button cancel" action="save" data-icon="check" />
<input type="submit" name="_action_save" value="Save" class="button cancel" action="save"/>
</div>
<g:render template="form"/>
... "form" has many, many fields in the form of:
<label for="section">Section</label>
<g:textField name="section" class="textfield required" value="${instance?.section}"/>
控制器逻辑是默认的save()脚手架,只有很少的修改:
@Secured(['IS_AUTHENTICATED_FULLY'])
def save = {
def instance = new Instance(params)
instance.setDescription("instancePE")
if(instance.instanceEnd == null){
flash.message = "${message(code: 'instance.time.null.message', args: [instance.mode.instanceHours])}"
render(view: "create", model: [instance: instance])
return
}
if (!validStartEnd(instance)) {
flash.message = "${message(code: 'instance.invalidRange.message', args: [instance.mode.instanceHours])}"
render(view: "create", model: [instance: instance])
return
}
instance.activeInstanceArchive =
g.render(template: "/templates/showInstances",model:
[loc: instance.instLocation])
def inst = super.save(instance, 'instance.label')
render(view: "create", model: [instance: inst])
}
域对象很大,但没有任何异常。它只列出要存储的对象。