Action errors in grid view struts2-jquery

I wanted to display action errors on top of the grid after doing some server side validation on the struts 2 values โ€‹โ€‹of the jQuery grid. Any help would be greatly appreciated.

here is my mistake of action.

addActionError("You can not delete this data"); 

But unfortunately, I cannot show the error on my jsp page. Share your knowledge on this issue.

+4
source share
2 answers

try it

Basic concept: you have to make one jsp.

Say error.jsp and when returning an error, just upload the file error.jsp.

In error.jsp write addActionError("You can not delete this data"); .

And include this .jsp error in your main grid page where you want to display the error message

0
source

to check on the server side, I use json response to the event after the transfer, as shown below

  navGrid("#pager2",{}, //options {height:280,width:700,reloadAfterSubmit:false}, // edit options {height:280,width:700,reloadAfterSubmit:false, afterSubmit : function(response, postdata) { var msg = "noError"; var res = $.parseJSON(response.responseText); if (res && res.userMessage) { alert(res.userMessage); msg = res.userMessage; } //alert(msg); if(msg == "noError") { return [true, "Validation pass"]; } else { return [false, msg]; } }}, // add options {reloadAfterSubmit:false}, // del options {} // search options ); 

and column entry

  <action name="jsontableEditValidationApartmentResource" class="com.loa.monitor.action.JsonActionResource" method="editValidate" > <result name="success" type = "json"></result> <result name="error" type="redirectAction"> <param name="actionName">proceedApartment</param> </result> </action> 

and method of action

  public String editValidate() { userMessage = "test msg1"; return "success"; } private String userMessage ; public String getUserMessage() { return userMessage; } public void setUserMessage(String userMessage) { this.userMessage = userMessage; } 

Let me know if this is helpful.

0
source

All Articles