root / trunk / web / dojo / dojox / wire / DataWire.js @ 11
History | View | Annotate | Download (1.7 KB)
1 |
/*
|
---|---|
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.wire.DataWire"]){ |
9 |
dojo._hasResource["dojox.wire.DataWire"]=true; |
10 |
dojo.provide("dojox.wire.DataWire");
|
11 |
dojo.require("dojox.wire.Wire");
|
12 |
dojo.declare("dojox.wire.DataWire",dojox.wire.Wire,{_wireClass:"dojox.wire.DataWire",constructor:function(_1){ |
13 |
if(!this.dataStore&&this.parent){ |
14 |
this.dataStore=this.parent.dataStore; |
15 |
} |
16 |
},_getValue:function(_2){ |
17 |
if(!_2||!this.attribute||!this.dataStore){ |
18 |
return _2;
|
19 |
} |
20 |
var _3=_2;
|
21 |
var _4=this.attribute.split("."); |
22 |
for(var i in _4){ |
23 |
_3=this._getAttributeValue(_3,_4[i]);
|
24 |
if(!_3){
|
25 |
return undefined; |
26 |
} |
27 |
} |
28 |
return _3;
|
29 |
},_setValue:function(_5,_6){ |
30 |
if(!_5||!this.attribute||!this.dataStore){ |
31 |
return _5;
|
32 |
} |
33 |
var _7=_5;
|
34 |
var _8=this.attribute.split("."); |
35 |
var _9=_8.length-1; |
36 |
for(var i=0;i<_9;i++){ |
37 |
_7=this._getAttributeValue(_7,_8[i]);
|
38 |
if(!_7){
|
39 |
return undefined; |
40 |
} |
41 |
} |
42 |
this._setAttributeValue(_7,_8[_9],_6);
|
43 |
return _5;
|
44 |
},_getAttributeValue:function(_a,_b){ |
45 |
var _c=undefined; |
46 |
var i1=_b.indexOf("["); |
47 |
if(i1>=0){ |
48 |
var i2=_b.indexOf("]"); |
49 |
var _d=_b.substring(i1+1,i2); |
50 |
_b=_b.substring(0,i1);
|
51 |
var _e=this.dataStore.getValues(_a,_b); |
52 |
if(_e){
|
53 |
if(!_d){
|
54 |
_c=_e; |
55 |
}else{
|
56 |
_c=_e[_d]; |
57 |
} |
58 |
} |
59 |
}else{
|
60 |
_c=this.dataStore.getValue(_a,_b);
|
61 |
} |
62 |
return _c;
|
63 |
},_setAttributeValue:function(_f,_10,_11){ |
64 |
var i1=_10.indexOf("["); |
65 |
if(i1>=0){ |
66 |
var i2=_10.indexOf("]"); |
67 |
var _12=_10.substring(i1+1,i2); |
68 |
_10=_10.substring(0,i1);
|
69 |
var _13=null; |
70 |
if(!_12){
|
71 |
_13=_11; |
72 |
}else{
|
73 |
_13=this.dataStore.getValues(_f,_10);
|
74 |
if(!_13){
|
75 |
_13=[]; |
76 |
} |
77 |
_13[_12]=_11; |
78 |
} |
79 |
this.dataStore.setValues(_f,_10,_13);
|
80 |
}else{
|
81 |
this.dataStore.setValue(_f,_10,_11);
|
82 |
} |
83 |
}}); |
84 |
} |