在保存jqgrid时,该操作捕获constraint violation exception
并返回“错误”。但是,不会在jsp上调用onEditInlineErrorTopics
函数。该异常需要转换为用户消息“Duplicate Records”
代码如下:
JSP网格代码
<sjg:grid id="gridtable"
dataType="json"
href="%{remoteurl}"
loadonce="true"
pager="true"
navigator="true"
scroll="true"
navigatorAdd="false"
navigatorEdit="false"
navigatorView="false"
navigatorDelete="true"
navigatorDeleteOptions="{height:220,reloadAfterSubmit:true,url:'%{deleteurl}'}"
gridModel="gridModel"
rowList="10,15,20"
rowNum="15"
navigatorRefresh="false"
navigatorSearch="false"
editurl="%{editurl}"
editinline="true"
navigatorInlineEditButtons="true"
gridview="true"
viewrecords="false"
shrinkToFit="true"
onEditInlineErrorTopics="onediterror">
也尝试过这些标签
errorElementId, errorText
&amp; onErrorTopics
动作标题(注释)
@ParentPackage(value = "basicstruts2")
@Action(value = "/editDetails",
results = {
@Result(name="success",type="json"),
@Result(name="error",type="json"),
@Result(name="none",type="json"),
@Result(name="input",type="json")
})
动作捕获块
catch(Exception e){
addActionError("Duplicate Records. Please enter again.");
return "error";
}
创建的Json
字符串是:
{"JSON":"error","field1":"1","field2":3,"oper":"edit","field3":5,"field4":"9","field5":null,"field6":null,"field7":"19","field8":156}
尝试在catch块中抛出exception
,但它会在弹出窗口中显示堆栈跟踪。
尝试了 in the showcase here 提到的成功主题onEditInlineSuccessTopics
,它运作良好。