Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.wire.CompositeWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.wire.CompositeWire"] = true;
3
dojo.provide("dojox.wire.CompositeWire");
4
 
5
dojo.require("dojox.wire._base");
6
dojo.require("dojox.wire.Wire");
7
 
8
dojo.declare("dojox.wire.CompositeWire", dojox.wire.Wire, {
9
	//	summary:
10
	//		A Wire for composite values in object or array
11
	//	description:
12
	//		This class has multiple child Wires for object properties or array
13
	//		elements.
14
	//		When an object with Wires is specified to 'children' property, they
15
	//		are used to get or set an object with property values.
16
	//		When an array of Wiares is specified to 'children' property, they
17
	//		are used to get or set an array with element values.
18
 
19
	_wireClass: "dojox.wire.CompositeWire",
20
 
21
	constructor: function(/*Object*/args){
22
		//	summary:
23
		//		Initialize properties
24
		//	description:
25
		//		If object properties or array elements specified in 'children'
26
		//		property are not Wires, Wires are created from them as
27
		//		arguments, with 'parent' property set to this Wire instance.
28
		//	args:
29
		//		Arguments to initialize properties
30
		//		children:
31
		//			An object or array containing child Wires
32
		this._initializeChildren(this.children);
33
	},
34
	_getValue: function(/*Object||Array*/object){
35
		//	summary:
36
		//		Return an object with property values or an array with element
37
		//		values
38
		//	description:
39
		//		This method calls getValue() method of the child Wires with
40
		//		'object' argument and returns an object with the values as
41
		//		properties or an arary of the values as elements.
42
		//	object:
43
		//		A root object
44
		//	returns:
45
		//		An object or array with values
46
		if(!object || !this.children){
47
			return object; //Object||Array
48
		}
49
 
50
		var value = (dojo.isArray(this.children) ? [] : {}); // array or object
51
		for(var c in this.children){
52
			value[c] = this.children[c].getValue(object);
53
		}
54
		return value;//Object||Array
55
	},
56
 
57
	_setValue: function(/*Object||Array*/object, /*Object||Array*/value){
58
		//	summary:
59
		//		Set an object properties or an array elements to an object
60
		//	desription:
61
		//		This method calls setValues() method of the child Wires with
62
		//		a corresponding property or element in 'value' argument and
63
		//		'object' argument.
64
		//	object:
65
		//		A root object
66
		//	value:
67
		//		An object or array with values to set
68
		//	returns:
69
		//		'object'
70
		if(!object || !this.children){
71
			return object; //Object||Array
72
		}
73
 
74
		for(var c in this.children){
75
			this.children[c].setValue(value[c], object);
76
		}
77
		return object; //Object||Array
78
	},
79
 
80
	_initializeChildren: function(/*Object||Array*/children){
81
		//	summary:
82
		//		Initialize child Wires
83
		//	description:
84
		//		If object properties or array elements specified in 'children'
85
		//		argument are not Wires, Wires are created from them as
86
		//		arguments, with 'parent' property set to this Wire instance.
87
		//	children:
88
		//		An object or array containing child Wires
89
		if(!children){
90
			return; //undefined
91
		}
92
 
93
		for(var c in children){
94
			var child = children[c];
95
			child.parent = this;
96
			if(!dojox.wire.isWire(child)){
97
				children[c] = dojox.wire.create(child);
98
			}
99
		}
100
	}
101
});
102
 
103
}