Error handling from server on mobile scheduler

Hi,
I’m trying to catch exceptions from the server side and deliver them to the client to display a message, but without success.
I wrote Servlet that gets the data from scheduler and performs update to DB by !nativeeditor_status then returns XML by the following structure:

<?xml version="1.0"?>
<data>
 <action type="updated" sid="422" tid="422" />
</data>

The servlet:

	boolean success = false;
			if (INSERT.equals(action)) {
				success = insertEvent(title, startTimestamp, endTimestamp, desc, location, status, type, result, username, userId, phoneNum);
				responseAction = " <action type=\"" + new String(success?"inserted":"error")+ "\" sid=\"" + id + "\" tid=\"" + id + "\" />";
			} else if (UPDATE.equals(action)) {
				success = updateEvent(id, title, startTimestamp, endTimestamp, desc, location, status, type, result, username, userId, phoneNum);
				responseAction = " <action type=\"" + new String(success?"updtaed":"error")+ "\" sid=\"" + id + "\" tid=\"" + id + "\" />";

			} else if (DELETE.equals(action)) {
				success = updateEvent(id, title, startTimestamp, endTimestamp, desc, location, STATUS_DELETE, type, result, username, userId, phoneNum);
				responseAction = " <action type=\"" + new String(success?"deleted":"error")+ "\" sid=\"" + id + "\" tid=\"" + id + "\" />";

			} else {
				log.error("The action is undefined");
				responseAction = " <action type=\"error\" sid=\"" + id + "\" tid=\"" + id + "\" />";
			}
				
	    out.println("<?xml version=\"1.0\"?>");
	    out.println("<data>");
	    out.println(responseAction);
	    out.println("</data>");
	    out.close();

On the client side:

dhx.ready(function() {
		dhx.ui.fullScreen();
		dhx.ui({
			view : "scheduler",
			id : "scheduler",
			save : "service/SchedulerActionService"
		});
		dhx.dp($$("scheduler")).attachEvent("onAfterUpdate",function(sid,action,tid,xml_node){
   if (action == "error"){
           alert(action);

   }
});

But it does not work. Did I do something wrong or is there another way?
Thanks, Guy.

Hello,

onAfterUpdate handler takes one parameter - an object with attributes of tag.

If the response is as in

the object will be {type:“update”, sid:“422”, tid:“422”}

dhx.dp($$(“scheduler”)).attachEvent(“onAfterUpdate”,function(action){
var id = action.sid;
return true;
});

Please note that “type” attribute in the xml is “update”, not “updated”

In case of the response with “error” type the DP will automatically call onDBError handler:

dhx.dp($$(“scheduler”)).attachEvent(“onDBError”,function(action,data){
// your code
return true;
});