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.