2

在保存 jqgrid 时,该操作捕获 aconstraint violation exception并返回“错误”。但是,该onEditInlineErrorTopics函数不会在 jsp 上调用。异常需要翻译成用户消息说“重复记录” 代码如下:

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&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}

尝试抛出exceptioncatch 块,但它在弹出窗口中显示堆栈跟踪。

尝试了此处展示onEditInlineSuccessTopics中提到的成功主题,效果很好。

4

0 回答 0