dedoz
16 Apr 2012, 9:17 AM
im using Ext 4.1rc2 and model/store with a Direct proxy.
my goal: get the message property in the response when sucess is false.
problem : when success is true, i can access operation.response.message and get that server message, but when success is false, operation.response its undefined so i cant get the message and tell the user what server said (why request failed)
server request can be any from model.load store.load model.save etc.
The model proxy has its reader root config set to data (note that everthing is working when server responde success:true and all records are loaded correctly )
my JSON response is
{ "type":"rpc",
"tid":1,
"action":"empQuery",
"method":"Insert",
"result":{ // comes inside result because Direct proxy reads "result" or "data" by default
"data":{"empId":"294","empRut":"11","empRazon":"test11"},
"success":true,
"message":"ok"
}
}
when operation fails in the server side i return a success:false and message property contains a message from server.
client side values when JSON response success : true
some_model_instance.save({
callback:function(record,operation) {
console.log(operation.wasSuccessful()); // true
console.log(operation); // displays the object
console.log(operation.response); // display the object with all response properties
}
});
client side values when JSON response success : false
some_model_instance.save({
callback:function(record,operation) {
console.log(operation.wasSuccessful()); // false
// detects correclty the success:false from the JSON
console.log(operation); // displays the object
console.log(operation.response); // undefined
}
});
so how can i access the message property when success: false ? why operation.response is undefined when success is false ? should i use another property to retrieve messages when success its false ?
my goal: get the message property in the response when sucess is false.
problem : when success is true, i can access operation.response.message and get that server message, but when success is false, operation.response its undefined so i cant get the message and tell the user what server said (why request failed)
server request can be any from model.load store.load model.save etc.
The model proxy has its reader root config set to data (note that everthing is working when server responde success:true and all records are loaded correctly )
my JSON response is
{ "type":"rpc",
"tid":1,
"action":"empQuery",
"method":"Insert",
"result":{ // comes inside result because Direct proxy reads "result" or "data" by default
"data":{"empId":"294","empRut":"11","empRazon":"test11"},
"success":true,
"message":"ok"
}
}
when operation fails in the server side i return a success:false and message property contains a message from server.
client side values when JSON response success : true
some_model_instance.save({
callback:function(record,operation) {
console.log(operation.wasSuccessful()); // true
console.log(operation); // displays the object
console.log(operation.response); // display the object with all response properties
}
});
client side values when JSON response success : false
some_model_instance.save({
callback:function(record,operation) {
console.log(operation.wasSuccessful()); // false
// detects correclty the success:false from the JSON
console.log(operation); // displays the object
console.log(operation.response); // undefined
}
});
so how can i access the message property when success: false ? why operation.response is undefined when success is false ? should i use another property to retrieve messages when success its false ?