root / trunk / web / dojo / dojox / wire / ml / Data.js @ 10
History | View | Annotate | Download (1.85 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.wire.ml.Data"]){ |
||
9 | dojo._hasResource["dojox.wire.ml.Data"]=true; |
||
10 | dojo.provide("dojox.wire.ml.Data");
|
||
11 | dojo.provide("dojox.wire.ml.DataProperty");
|
||
12 | dojo.require("dijit._Widget");
|
||
13 | dojo.require("dijit._Container");
|
||
14 | dojo.require("dojox.wire.ml.util");
|
||
15 | dojo.declare("dojox.wire.ml.Data",[dijit._Widget,dijit._Container],{startup:function(){ |
||
16 | this._initializeProperties();
|
||
17 | },_initializeProperties:function(_1){ |
||
18 | if(!this._properties||_1){ |
||
19 | this._properties={};
|
||
20 | } |
||
21 | var _2=this.getChildren(); |
||
22 | for(var i in _2){ |
||
23 | var _3=_2[i];
|
||
24 | if((_3 instanceof dojox.wire.ml.DataProperty)&&_3.name){ |
||
25 | this.setPropertyValue(_3.name,_3.getValue());
|
||
26 | } |
||
27 | } |
||
28 | },getPropertyValue:function(_4){ |
||
29 | return this._properties[_4]; |
||
30 | },setPropertyValue:function(_5,_6){ |
||
31 | this._properties[_5]=_6;
|
||
32 | }}); |
||
33 | dojo.declare("dojox.wire.ml.DataProperty",[dijit._Widget,dijit._Container],{name:"",type:"",value:"",_getValueAttr:function(){ |
||
34 | return this.getValue(); |
||
35 | },getValue:function(){ |
||
36 | var _7=this.value; |
||
37 | if(this.type){ |
||
38 | if(this.type=="number"){ |
||
39 | _7=parseInt(_7); |
||
40 | }else{
|
||
41 | if(this.type=="boolean"){ |
||
42 | _7=(_7=="true");
|
||
43 | }else{
|
||
44 | if(this.type=="array"){ |
||
45 | _7=[]; |
||
46 | var _8=this.getChildren(); |
||
47 | for(var i in _8){ |
||
48 | var _9=_8[i];
|
||
49 | if(_9 instanceof dojox.wire.ml.DataProperty){ |
||
50 | _7.push(_9.getValue()); |
||
51 | } |
||
52 | } |
||
53 | }else{
|
||
54 | if(this.type=="object"){ |
||
55 | _7={}; |
||
56 | var _8=this.getChildren(); |
||
57 | for(var i in _8){ |
||
58 | var _9=_8[i];
|
||
59 | if((_9 instanceof dojox.wire.ml.DataProperty)&&_9.name){ |
||
60 | _7[_9.name]=_9.getValue(); |
||
61 | } |
||
62 | } |
||
63 | }else{
|
||
64 | if(this.type=="element"){ |
||
65 | _7=new dojox.wire.ml.XmlElement(_7);
|
||
66 | var _8=this.getChildren(); |
||
67 | for(var i in _8){ |
||
68 | var _9=_8[i];
|
||
69 | if((_9 instanceof dojox.wire.ml.DataProperty)&&_9.name){ |
||
70 | _7.setPropertyValue(_9.name,_9.getValue()); |
||
71 | } |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | } |
||
79 | return _7;
|
||
80 | }}); |
||
81 | } |