Changeset 1562
- Timestamp:
- 04/23/08 09:24:37 (3 weeks ago)
- Files:
-
- trunk/src/main/javascript/stub-json-rpc-debug.js (modified) (1 diff)
- trunk/src/main/javascript/stub-json-rpc.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/javascript/stub-json-rpc-debug.js
r1170 r1562 28 28 success: function(o) { 29 29 var rpcObj = o.responseText.parseJSON(); 30 if ( rpcObj.error === null ) { 31 for (var i=0; i < reqRespMapping.length; i++) { 32 if (rpcObj.id === reqRespMapping[i].id) { 33 var classAndMethod = reqRespMapping[i].method.split("."); 34 console.info("Stubbles::REQID " + rpcObj.id + " :: Calling callback method callback__" + classAndMethod[1] + "("+rpcObj.id+", "+rpcObj.result+", "+rpcObj.error+")"); 35 var methodName = 'callback__' + classAndMethod[1]; 30 for (var i=0; i < reqRespMapping.length; i++) { 31 if (rpcObj.id === reqRespMapping[i].id) { 32 var classAndMethod = reqRespMapping[i].method.split("."); 33 console.info("Stubbles::REQID " + rpcObj.id + " :: Calling callback method callback__" + classAndMethod[1] + "("+rpcObj.id+", "+rpcObj.result+", "+rpcObj.error+")"); 34 var methodName = 'callback__' + classAndMethod[1]; 36 35 37 // call callback method on clientObj 38 clientObj[methodName].call(clientObj, rpcObj.id, rpcObj.result, rpcObj.error); 39 return; 36 // call callback method on clientObj 37 if ( rpcObj.error === null ) { 38 clientObj[methodName].call(clientObj, rpcObj.id, rpcObj.result, rpcObj.error); 39 } else { 40 console.error("Stubbles::REQID " + rpcObj.id + " :: ERROR: " + rpcObj.error); 41 clientObj[methodName].call(clientObj, rpcObj.id, null, rpcObj.error); 40 42 } 43 return; 41 44 } 42 console.error("Stubbles::REQID " + rpcObj.id + " :: Invalid request id.");43 throw 'stubbles: no related request id for response id found - mapping in js obj reqRespMapping failed!';44 } else {45 console.error("Stubbles::REQID " + rpcObj.id + " :: ERROR: " + rpcObj.error);46 throw rpcObj.error;47 45 } 46 console.error("Stubbles::REQID " + rpcObj.id + " :: Invalid request id."); 47 var errorMsg = 'stubbles: no related request id for response id found - mapping in js obj reqRespMapping failed!'; 48 clientObj[methodName].call(clientObj, rpcObj.id, null, errorMsg); 48 49 }, 49 50 failure: function(o) { 50 51 console.error("Stubbles::REQID n/a :: ERROR: HTTP Request failed."); 51 throw 'stubbles: callback error due to bad request from service (instead of HTTP status code 200)'; 52 var errorMsg = 'stubbles: callback error due to bad request from service (instead of HTTP status code 200)'; 53 clientObj[methodName].call(clientObj, rpcObj.id, null, errorMsg); 52 54 } 53 55 }; trunk/src/main/javascript/stub-json-rpc.js
r1170 r1562 28 28 success: function(o) { 29 29 var rpcObj = o.responseText.parseJSON(); 30 if ( rpcObj.error === null ) { 31 for (var i=0; i < reqRespMapping.length; i++) { 32 if (rpcObj.id === reqRespMapping[i].id) { 33 var classAndMethod = reqRespMapping[i].method.split("."); 34 var methodName = 'callback__' + classAndMethod[1]; 30 for (var i=0; i < reqRespMapping.length; i++) { 31 if (rpcObj.id === reqRespMapping[i].id) { 32 var classAndMethod = reqRespMapping[i].method.split("."); 33 var methodName = 'callback__' + classAndMethod[1]; 35 34 36 // call callback method on clientObj 37 clientObj[methodName].call(clientObj, rpcObj.id, rpcObj.result, rpcObj.error); 38 return; 35 // call callback method on clientObj 36 if ( rpcObj.error === null ) { 37 clientObj[methodName].call(clientObj, rpcObj.id, rpcObj.result, rpcObj.error); 38 } else { 39 clientObj[methodName].call(clientObj, rpcObj.id, null, rpcObj.error); 39 40 } 41 return; 40 42 } 41 throw 'stubbles: no related request id for response id found - mapping in js obj reqRespMapping failed!';42 } else {43 throw rpcObj.error;44 43 } 44 var errorMsg = 'stubbles: no related request id for response id found - mapping in js obj reqRespMapping failed!'; 45 clientObj[methodName].call(clientObj, rpcObj.id, null, errorMsg); 45 46 }, 46 47 failure: function(o) { 47 throw 'stubbles: callback error due to bad request from service (instead of HTTP status code 200)'; 48 var errorMsg = 'stubbles: callback error due to bad request from service (instead of HTTP status code 200)'; 49 clientObj[methodName].call(clientObj, rpcObj.id, null, errorMsg); 48 50 } 49 51 };
