source: Dev/trunk/src/client/dojox/form/manager/_ValueMixin.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.2 KB
Line 
1define([
2        "dojo/_base/lang",
3        "dojo/_base/kernel",
4        "dojo/_base/declare"
5], function(lang, dojo, declare){
6return declare("dojox.form.manager._ValueMixin", null, {
7        // summary:
8        //              Form manager's mixin for getting/setting form values in the unified manner.
9        // description:
10        //              This mixin adds unified access to form widgets and form elements
11        //              in terms of name-value regardless of the underlying type of
12        //              an element. It should be used together with dojox.form.manager.Mixin.
13
14        elementValue: function(name, value){
15                // summary:
16                //              Set or get a form widget/element or an attached point node by name.
17                // name: String
18                //              The name.
19                // value: Object?
20                //              Optional. The value to set.
21
22                if(name in this.formWidgets){
23                        return this.formWidgetValue(name, value);       // Object
24                }
25
26                if(this.formNodes && name in this.formNodes){
27                        return this.formNodeValue(name, value); // Object
28                }
29
30                return this.formPointValue(name, value);        // Object
31        },
32
33        gatherFormValues: function(names){
34                // summary:
35                //              Collect form values.
36                // names: Object?
37                //              If it is an array, it is a list of names of form elements to be collected.
38                //              If it is an object, dictionary keys are names to be collected.
39                //              If it is omitted, all known form elements are to be collected.
40
41                var result = this.inspectFormWidgets(function(name){
42                        return this.formWidgetValue(name);
43                }, names);
44
45                if(this.inspectFormNodes){
46                        lang.mixin(result, this.inspectFormNodes(function(name){
47                                return this.formNodeValue(name);
48                        }, names));
49                }
50
51                lang.mixin(result, this.inspectAttachedPoints(function(name){
52                        return this.formPointValue(name);
53                }, names));
54
55                return result;  // Object
56        },
57
58        setFormValues: function(values){
59                // summary:
60                //              Set values to form elements
61                // values: Object
62                //              A dictionary of key-value pairs.
63                if(values){
64                        this.inspectFormWidgets(function(name, widget, value){
65                                this.formWidgetValue(name, value);
66                        }, values);
67
68                        if(this.inspectFormNodes){
69                                this.inspectFormNodes(function(name, node, value){
70                                        this.formNodeValue(name, value);
71                                }, values);
72                        }
73
74                        this.inspectAttachedPoints(function(name, node, value){
75                                this.formPointValue(name, value);
76                        }, values);
77                }
78                return this;
79        }
80});
81});
Note: See TracBrowser for help on using the repository browser.