2

On save of the jqgrid, the action catches a constraint violation exception and returns "error". However, the onEditInlineErrorTopics function is not called on the jsp. The exception needs to be translated to a user message saying "Duplicate Records" The code is as follows:

JSP grid Code

<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">

Tried these tags as well errorElementId, errorText & onErrorTopics

Action header (annotations)

@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")
})

Action catch block

catch(Exception e){
addActionError("Duplicate Records. Please enter again.");
return "error";
}

The Json string created is: {"JSON":"error","field1":"1","field2":3,"oper":"edit","field3":5,"field4":"9","field5":null,"field6":null,"field7":"19","field8":156}

Tried throwing exception in the catch block but it shows the stacktrace in a popup.

Tried the success topic onEditInlineSuccessTopics as mentioned in the showcase here and it works fine.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Vickym
  • 137
  • 2
  • 10

0 Answers0