diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojo/rpc/JsonpService.js | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2 |
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojo/rpc/JsonpService.js')
-rw-r--r-- | includes/js/dojo/rpc/JsonpService.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/includes/js/dojo/rpc/JsonpService.js b/includes/js/dojo/rpc/JsonpService.js new file mode 100644 index 0000000..c07d5b9 --- /dev/null +++ b/includes/js/dojo/rpc/JsonpService.js @@ -0,0 +1,65 @@ +if(!dojo._hasResource["dojo.rpc.JsonpService"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojo.rpc.JsonpService"] = true; +dojo.provide("dojo.rpc.JsonpService"); +dojo.require("dojo.rpc.RpcService"); +dojo.require("dojo.io.script"); + +dojo.declare("dojo.rpc.JsonpService", dojo.rpc.RpcService, { + // summary: + // Generic JSONP service. Minimally extends RpcService to allow + // easy definition of nearly any JSONP style service. Example + // SMD files exist in dojox.data + + constructor: function(args, requiredArgs){ + if(this.required) { + if(requiredArgs){ + dojo.mixin(this.required, requiredArgs); + } + + dojo.forEach(this.required, function(req){ + if(req=="" || req==undefined){ + throw new Error("Required Service Argument not found: "+req); + } + }); + } + }, + + strictArgChecks: false, + + bind: function(method, parameters, deferredRequestHandler, url){ + //summary: + // JSONP bind method. Takes remote method, parameters, + // deferred, and a url, calls createRequest to make a JSON-RPC + // envelope and passes that off with bind. + // method: string + // The name of the method we are calling + // parameters: array + // The parameters we are passing off to the method + // deferredRequestHandler: deferred + // The Deferred object for this particular request + + var def = dojo.io.script.get({ + url: url||this.serviceUrl, + callbackParamName: this.callbackParamName||"callback", + content: this.createRequest(parameters), + timeout: this.timeout, + handleAs: "json", + preventCache: true + }); + def.addCallbacks(this.resultCallback(deferredRequestHandler), this.errorCallback(deferredRequestHandler)); + }, + + createRequest: function(parameters){ + // summary: + // create a JSONP req + // params: array + // The array of parameters for this request; + + var params = (dojo.isArrayLike(parameters) && parameters.length==1) ? + parameters[0] : {}; + dojo.mixin(params,this.required); + return params; + } +}); + +} |