This is a migrated thread and some comments may be shown as answers.

How to handle a Java Servlet error

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 03 Oct 2014, 06:07 PM
I am VERY new to all of this so I ask that you please bear with me.  I am using the Grid and have the editable.mode set to "popup".  I have changed the backend Java Servlet to have an SQL error on purpose to figure out how to do error handling.

In the client javascript for Kendo Grid I have the following which I basically cut and pasted from an example.

schema: {

                errors: "error",

                error : function(e) {
                    alert(e.errors);
                },

I have no idea what I need to do in the servlet in order to send an appropriate error to the client code such that it will be caught.  I tried this but it isn't working:
response.sendError(422, "error: " + exception.getMessage());




1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 07 Oct 2014, 04:18 PM
Hello Steve,

Is the alert that you put in the error handler displayed, is the event triggered? If it is triggered the only thing left to do is to prevent the rebinding of the Grid by preventing the next dataBinding event:

$("#gridName").data("kendoGrid").one("dataBinding", function(e){
      e.preventDefault();
})

Inside the event argument of the error event handler of the dataSource you should have access to the raw response from the server -> e.xhr

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events-error

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or