Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
1.0 KB
|
Line | |
---|
1 | dojo.provide("dojox.wire.ml.JsonHandler"); |
---|
2 | |
---|
3 | dojo.require("dojox.wire.ml.RestHandler"); |
---|
4 | dojo.require("dojox.wire._base"); |
---|
5 | dojo.require("dojox.wire.ml.util"); |
---|
6 | |
---|
7 | |
---|
8 | dojo.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.