source: Dev/trunk/src/client/dojox/wire/ml/JsonHandler.js @ 483

Last change on this file since 483 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.0 KB
Line 
1dojo.provide("dojox.wire.ml.JsonHandler");
2
3dojo.require("dojox.wire.ml.RestHandler");
4dojo.require("dojox.wire._base");
5dojo.require("dojox.wire.ml.util");
6
7
8dojo.declare("dojox.wire.ml.JsonHandler", dojox.wire.ml.RestHandler, {
9        // summary:
10        //              A REST service handler for JSON
11        // description:
12        //              This class provides JSON handling for a REST service.
13        contentType: "text/json",
14        handleAs: "json",
15        headers: {"Accept": "*/json"},
16
17        _getContent: function(/*String*/method, /*Array*/parameters){
18                // summary:
19                //              Generate a request content
20                // description:
21                //              If 'method' is "POST" or "PUT", the first parameter in
22                //              'parameter' is used to generate a JSON content.
23                // method:
24                //              A method name
25                // parameters:
26                //              An array of parameters
27                // returns:
28                //              A request content
29                var content = null;
30                if(method == "POST" || method == "PUT"){
31                        var p = (parameters ? parameters[0] : undefined);
32                        if(p){
33                                if(dojo.isString(p)){
34                                        content = p;
35                                }else{
36                                        content = dojo.toJson(p);
37                                }
38                        }
39                }
40                return content; //String
41        }
42});
Note: See TracBrowser for help on using the repository browser.