root / trunk / web / dojo / dojox / data / PersevereStore.js
History | View | Annotate | Download (2.25 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.data.PersevereStore"]){ |
||
9 | dojo._hasResource["dojox.data.PersevereStore"]=true; |
||
10 | dojo.provide("dojox.data.PersevereStore");
|
||
11 | dojo.require("dojox.data.JsonQueryRestStore");
|
||
12 | dojo.require("dojox.rpc.Client");
|
||
13 | dojox.json.ref.serializeFunctions=true;
|
||
14 | dojo.declare("dojox.data.PersevereStore",dojox.data.JsonQueryRestStore,{useFullIdInQueries:true,jsonQueryPagination:false}); |
||
15 | dojox.data.PersevereStore.getStores=function(_1,_2){ |
||
16 | _1=(_1&&(_1.match(/\/$/)?_1:(_1+"/")))||"/"; |
||
17 | if(_1.match(/^\w*:\/\//)){ |
||
18 | dojo.require("dojox.io.xhrScriptPlugin");
|
||
19 | dojox.io.xhrScriptPlugin(_1,"callback",dojox.io.xhrPlugins.fullHttpAdapter);
|
||
20 | } |
||
21 | var _3=dojo.xhr;
|
||
22 | dojo.xhr=function(_4,_5){ |
||
23 | (_5.headers=_5.headers||{})["Server-Methods"]="false"; |
||
24 | return _3.apply(dojo,arguments); |
||
25 | }; |
||
26 | var _6=dojox.rpc.Rest(_1,true); |
||
27 | dojox.rpc._sync=_2; |
||
28 | var _7=_6("Class/"); |
||
29 | var _8;
|
||
30 | var _9={};
|
||
31 | var _a=0; |
||
32 | _7.addCallback(function(_b){
|
||
33 | dojox.json.ref.resolveJson(_b,{index:dojox.rpc.Rest._index,idPrefix:"/Class/",assignAbsoluteIds:true}); |
||
34 | function _c(_d){ |
||
35 | if(_d["extends"]&&_d["extends"].prototype){ |
||
36 | if(!_d.prototype||!_d.prototype.isPrototypeOf(_d["extends"].prototype)){ |
||
37 | _c(_d["extends"]);
|
||
38 | dojox.rpc.Rest._index[_d.prototype.__id]=_d.prototype=dojo.mixin(dojo.delegate(_d["extends"].prototype),_d.prototype);
|
||
39 | } |
||
40 | } |
||
41 | }; |
||
42 | function _e(_f,_10){ |
||
43 | if(_f&&_10){
|
||
44 | for(var j in _f){ |
||
45 | var _11=_f[j];
|
||
46 | if(_11.runAt!="client"&&!_10[j]){ |
||
47 | _10[j]=(function(_12){
|
||
48 | return function(){ |
||
49 | var _13=dojo.rawXhrPost({url:this.__id,postData:dojo.toJson({method:_12,id:_a++,params:dojo._toArray(arguments)}),handleAs:"json"}); |
||
50 | _13.addCallback(function(_14){
|
||
51 | return _14.error?new Error(_14.error):_14.result; |
||
52 | }); |
||
53 | return _13;
|
||
54 | }; |
||
55 | })(j); |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 | }; |
||
60 | for(var i in _b){ |
||
61 | if(typeof _b[i]=="object"){ |
||
62 | var _15=_b[i];
|
||
63 | _c(_15); |
||
64 | _e(_15.methods,_15.prototype=_15.prototype||{}); |
||
65 | _e(_15.staticMethods,_15); |
||
66 | _9[_b[i].id]=new dojox.data.PersevereStore({target:new dojo._Url(_1,_b[i].id)+"/",schema:_15}); |
||
67 | } |
||
68 | } |
||
69 | return (_8=_9);
|
||
70 | }); |
||
71 | dojo.xhr=_3; |
||
72 | return _2?_8:_7;
|
||
73 | }; |
||
74 | dojox.data.PersevereStore.addProxy=function(){ |
||
75 | dojo.require("dojox.io.xhrPlugins");
|
||
76 | dojox.io.xhrPlugins.addProxy("/proxy/");
|
||
77 | }; |
||
78 | } |