Hello all,
I am using JSON-RPC to create an instance of 'RpcManager' on server side:
In java:
bridge.registerCallableReference(com.xilinx.xgr.bat.rpc.RpcManager.class);
bridge.registerClass("RpcManager",com.xilinx.xgr.bat.rpc.RpcManager.class);
In Javascript:
this.__jsonrpc = new JSONRpcClient("/bat/JSON-RPC")
this.__manager = this.__jsonrpc.RpcManager.getInstance(); // Get the
RpcManager instance for the session
The RpcManager has a 'getUser' method which return a JavaBean User object.
Doing a this.__manager.getUser() works fine, but using the async call,
by doing this.__manager.getUser(cb) errors out with:
uncaught exception: [Exception... "Component returned failure code:
0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]"
nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame ::
javascript: eval(__firebugTemp__); :: anonymous :: line 1" data: no]
When debugging, it appears that the first arg ('client') of the
_sendRequest differs:
+ When using sync, it is the JSONRpcClient
+ When using async, it is the CallableReference (javaClass =
"com.xilinx.xgr.bat.rpc.RpcManager"):
As the 'client.serverURL' (used in http.open) is not defined, the
error is trhow.
I have the feeling that client object given to the _sendRequest is not
the good one when using async call.
I did hack the JSONRpcClient._createMethod to fix the problem (see below).
What do you think about this fix ?
Thanks a lot,
Charles.
JSONRpcClient._createMethod = function (client,methodName)
{
//This function is what the user calls.
//This function uses a closure on methodName to ensure that the function
//always has the same name, but can take different arguments each call.
//Each time it is added to an object this should be set with bind()
var serverMethodCaller= function()
{
var args = [],
callback;
for (var i = 0; i < arguments.length; i++)
{
args.push(arguments[i]);
}
if (typeof args[0] == "function")
{
callback = args.shift();
}
var req = JSONRpcClient._makeRequest(this, methodName, args,
this.objectID,callback);
if (!callback)
{
return JSONRpcClient._sendRequest(client, req);
}
else
{
//when there is a callback, add the req to the list
+ req.client = client; // WORKAROUND
JSONRpcClient.async_requests.push(req);
JSONRpcClient.kick_async();
return req.requestId;
}
};
return serverMethodCaller;
};
_______________________________________________
Jabsorb-dev mailing list
[email protected]
http://lists.jabsorb.org/mailman/listinfo/jabsorb-dev