summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/wire
diff options
context:
space:
mode:
Diffstat (limited to 'js/dojo/dojox/wire')
-rw-r--r--js/dojo/dojox/wire/CompositeWire.js104
-rw-r--r--js/dojo/dojox/wire/DataWire.js180
-rw-r--r--js/dojo/dojox/wire/README54
-rw-r--r--js/dojo/dojox/wire/TableAdapter.js89
-rw-r--r--js/dojo/dojox/wire/TextAdapter.js89
-rw-r--r--js/dojo/dojox/wire/TreeAdapter.js189
-rw-r--r--js/dojo/dojox/wire/Wire.js382
-rw-r--r--js/dojo/dojox/wire/XmlWire.js247
-rw-r--r--js/dojo/dojox/wire/_base.js196
-rw-r--r--js/dojo/dojox/wire/demos/TableContainer.css30
-rw-r--r--js/dojo/dojox/wire/demos/TableContainer.js69
-rw-r--r--js/dojo/dojox/wire/demos/WidgetRepeater.js34
-rw-r--r--js/dojo/dojox/wire/demos/markup/countries.json43
-rw-r--r--js/dojo/dojox/wire/demos/markup/demo_ActionChaining.html112
-rw-r--r--js/dojo/dojox/wire/demos/markup/demo_ActionWiring.html138
-rw-r--r--js/dojo/dojox/wire/demos/markup/demo_BasicChildWire.html78
-rw-r--r--js/dojo/dojox/wire/demos/markup/demo_BasicColumnWiring.html90
-rw-r--r--js/dojo/dojox/wire/demos/markup/demo_ConditionalActions.html221
-rw-r--r--js/dojo/dojox/wire/demos/markup/demo_FlickrStoreWire.html227
-rw-r--r--js/dojo/dojox/wire/demos/markup/demo_TopicWiring.html84
-rw-r--r--js/dojo/dojox/wire/demos/markup/flickrDemo.css35
-rw-r--r--js/dojo/dojox/wire/demos/markup/states.json56
-rw-r--r--js/dojo/dojox/wire/ml/Action.js225
-rw-r--r--js/dojo/dojox/wire/ml/Data.js147
-rw-r--r--js/dojo/dojox/wire/ml/DataStore.js117
-rw-r--r--js/dojo/dojox/wire/ml/Invocation.js172
-rw-r--r--js/dojo/dojox/wire/ml/JsonHandler.js47
-rw-r--r--js/dojo/dojox/wire/ml/RestHandler.js148
-rw-r--r--js/dojo/dojox/wire/ml/Service.js107
-rw-r--r--js/dojo/dojox/wire/ml/Transfer.js356
-rw-r--r--js/dojo/dojox/wire/ml/XmlHandler.js68
-rw-r--r--js/dojo/dojox/wire/ml/util.js300
32 files changed, 4434 insertions, 0 deletions
diff --git a/js/dojo/dojox/wire/CompositeWire.js b/js/dojo/dojox/wire/CompositeWire.js
new file mode 100644
index 0000000..a887bd0
--- /dev/null
+++ b/js/dojo/dojox/wire/CompositeWire.js
@@ -0,0 +1,104 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/CompositeWire", ["dijit","dojo","dojox","dojo/require!dojox/wire/_base,dojox/wire/Wire"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.CompositeWire");
+
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.CompositeWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for composite values in object or array
+ // description:
+ // This class has multiple child Wires for object properties or array
+ // elements.
+ // When an object with Wires is specified to 'children' property, they
+ // are used to get or set an object with property values.
+ // When an array of Wiares is specified to 'children' property, they
+ // are used to get or set an array with element values.
+
+ _wireClass: "dojox.wire.CompositeWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties or array elements specified in 'children'
+ // property are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // children:
+ // An object or array containing child Wires
+ this._initializeChildren(this.children);
+ },
+ _getValue: function(/*Object||Array*/object){
+ // summary:
+ // Return an object with property values or an array with element
+ // values
+ // description:
+ // This method calls getValue() method of the child Wires with
+ // 'object' argument and returns an object with the values as
+ // properties or an arary of the values as elements.
+ // object:
+ // A root object
+ // returns:
+ // An object or array with values
+ if(!object || !this.children){
+ return object; //Object||Array
+ }
+
+ var value = (dojo.isArray(this.children) ? [] : {}); // array or object
+ for(var c in this.children){
+ value[c] = this.children[c].getValue(object);
+ }
+ return value;//Object||Array
+ },
+
+ _setValue: function(/*Object||Array*/object, /*Object||Array*/value){
+ // summary:
+ // Set an object properties or an array elements to an object
+ // desription:
+ // This method calls setValues() method of the child Wires with
+ // a corresponding property or element in 'value' argument and
+ // 'object' argument.
+ // object:
+ // A root object
+ // value:
+ // An object or array with values to set
+ // returns:
+ // 'object'
+ if(!object || !this.children){
+ return object; //Object||Array
+ }
+
+ for(var c in this.children){
+ this.children[c].setValue(value[c], object);
+ }
+ return object; //Object||Array
+ },
+
+ _initializeChildren: function(/*Object||Array*/children){
+ // summary:
+ // Initialize child Wires
+ // description:
+ // If object properties or array elements specified in 'children'
+ // argument are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // children:
+ // An object or array containing child Wires
+ if(!children){
+ return; //undefined
+ }
+
+ for(var c in children){
+ var child = children[c];
+ child.parent = this;
+ if(!dojox.wire.isWire(child)){
+ children[c] = dojox.wire.create(child);
+ }
+ }
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/DataWire.js b/js/dojo/dojox/wire/DataWire.js
new file mode 100644
index 0000000..466bad9
--- /dev/null
+++ b/js/dojo/dojox/wire/DataWire.js
@@ -0,0 +1,180 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/DataWire", ["dijit","dojo","dojox","dojo/require!dojox/wire/Wire"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.DataWire");
+
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.DataWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for item attributes of data stores
+ // description:
+ // This class accesses item attributes of data stores with a dotted
+ // notation of attribute names specified to 'attribute' property,
+ // using data APIs of a data store specified to 'dataStore' property.
+ // The root object for this class must be an item of the data store.
+ // Intermediate attribute names in the dotted notation specify
+ // attributes for child items, which are used for repeated calls to
+ // data APIs until reached to a descendant attribute.
+ // Attribute names may have an array index, such as "a[0]", to
+ // identify an array element of the attribute value.
+
+ _wireClass: "dojox.wire.DataWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If 'dataStore' property is not specified, but 'parent' property
+ // is specified, 'dataStore' property is copied from the parent.
+ // args:
+ // Arguments to initialize properties
+ // dataStore:
+ // A data store
+ // attribute:
+ // A dotted notation to a descendant attribute
+ if(!this.dataStore && this.parent){
+ this.dataStore = this.parent.dataStore;
+ }
+ },
+ _getValue: function(/*Object*/object){
+ // summary:
+ // Return an attribute value of an item
+ // description:
+ // This method uses a root item passed in 'object' argument and
+ // 'attribute' property to call getValue() method of
+ // 'dataStore'.
+ // If an attribute name have an array suffix ("[]"), getValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is returned, instead of the array itself.
+ // object:
+ // A root item
+ // returns:
+ // A value found, otherwise 'undefined'
+ if(!object || !this.attribute || !this.dataStore){
+ return object; //Object
+ }
+
+ var value = object;
+ var list = this.attribute.split('.');
+ for(var i in list){
+ value = this._getAttributeValue(value, list[i]);
+ if(!value){
+ return undefined; //undefined
+ }
+ }
+ return value; //anything
+ },
+
+ _setValue: function(/*Object*/object, /*anything*/value){
+ // summary:
+ // Set an attribute value to an item
+ // description:
+ // This method uses a root item passed in 'object' argument and
+ // 'attribute' property to identify an item.
+ // Then, setValue() method of 'dataStore' is called with a leaf
+ // attribute name and 'value' argument.
+ // If an attribute name have an array suffix ("[]"), setValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is set to 'value', instead of the array itself.
+ // object:
+ // A root item
+ // value:
+ // A value to set
+ // returns:
+ // 'object', or 'undefined' for invalid attribute
+ if(!object || !this.attribute || !this.dataStore){
+ return object; //Object
+ }
+
+ var item = object;
+ var list = this.attribute.split('.');
+ var last = list.length - 1;
+ for(var i = 0; i < last; i++){
+ item = this._getAttributeValue(item, list[i]);
+ if(!item){
+ return undefined; //undefined
+ }
+ }
+ this._setAttributeValue(item, list[last], value);
+ return object; //Object
+ },
+
+ _getAttributeValue: function(/*Object*/item, /*String*/attribute){
+ // summary:
+ // Return an attribute value of an item
+ // description:
+ // This method uses an item passed in 'item' argument and
+ // 'attribute' argument to call getValue() method of 'dataStore'.
+ // If an attribute name have an array suffix ("[]"), getValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is returned, instead of the array itself.
+ // item:
+ // An item
+ // attribute
+ // An attribute name
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ var i1 = attribute.indexOf('[');
+ if(i1 >= 0){
+ var i2 = attribute.indexOf(']');
+ var index = attribute.substring(i1 + 1, i2);
+ attribute = attribute.substring(0, i1);
+ var array = this.dataStore.getValues(item, attribute);
+ if(array){
+ if(!index){ // return array for "attribute[]"
+ value = array;
+ }else{
+ value = array[index];
+ }
+ }
+ }else{
+ value = this.dataStore.getValue(item, attribute);
+ }
+ return value; //anything
+ },
+
+ _setAttributeValue: function(/*Object*/item, /*String*/attribute, /*anything*/value){
+ // summary:
+ // Set an attribute value to an item
+ // description:
+ // This method uses an item passed in 'item' argument and
+ // 'attribute' argument to call setValue() method of 'dataStore'
+ // with 'value' argument.
+ // If an attribute name have an array suffix ("[]"), setValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is set to 'value', instead of the array itself.
+ // item:
+ // An item
+ // attribute:
+ // An attribute name
+ // value:
+ // A value to set
+ var i1 = attribute.indexOf('[');
+ if(i1 >= 0){
+ var i2 = attribute.indexOf(']');
+ var index = attribute.substring(i1 + 1, i2);
+ attribute = attribute.substring(0, i1);
+ var array = null;
+ if(!index){ // replace whole array for "attribute[]"
+ array = value;
+ }else{
+ array = this.dataStore.getValues(item, attribute);
+ if(!array){
+ array = [];
+ }
+ array[index] = value;
+ }
+ this.dataStore.setValues(item, attribute, array);
+ }else{
+ this.dataStore.setValue(item, attribute, value);
+ }
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/README b/js/dojo/dojox/wire/README
new file mode 100644
index 0000000..d33edee
--- /dev/null
+++ b/js/dojo/dojox/wire/README
@@ -0,0 +1,54 @@
+-------------------------------------------------------------------------------
+DojoX Wire
+-------------------------------------------------------------------------------
+Version 1.0
+Release date: 05/29/2007
+-------------------------------------------------------------------------------
+Project state: production
+-------------------------------------------------------------------------------
+Project authors
+ Jared Jurkiewicz (jared.jurkiewicz@gmail.com)
+-------------------------------------------------------------------------------
+Project description
+
+The DojoX Wire project is a set of functions that build a generic data binding
+and service invocation library to simplify how data values across a wide
+variety of widget and non-widget JavaScript constructs are accessed, updated,
+and passed to and from services. It also provides a set of widgets
+within the dojox.wire.ml package to allow for declarative data binding
+definitions in addition to the programmatic APIs.
+
+In essense, this project is an API to provide a simplified way of doing MVC
+patterns in the client.
+
+-------------------------------------------------------------------------------
+Dependencies:
+
+DojoX Wire has dependencies on core dojo, the dijit widget system (for classes
+in the dojox.wire.ml package), dojox.data, dojox.xml, and the D.O.H. unit test
+framework.
+-------------------------------------------------------------------------------
+Documentation:
+
+See the Dojo API tool (http://dojotoolkit.org/api)
+-------------------------------------------------------------------------------
+Installation instructions
+
+Grab the following from the Dojo SVN Repository:
+http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire.js
+http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire/*
+
+Install into the following directory structure:
+/dojox/wire/
+
+...which should be at the same level as your Dojo checkout.
+
+It should look like:
+/dojox/wire.js
+/dojox/wire/*
+
+Require in dojox.wire for all baseline functions (dojox.wire.connect,
+dojox.wire.register, etc). For specific Wire classes,
+require in the appropriate dojox.wire.<Class>.
+-------------------------------------------------------------------------------
+
diff --git a/js/dojo/dojox/wire/TableAdapter.js b/js/dojo/dojox/wire/TableAdapter.js
new file mode 100644
index 0000000..5171272
--- /dev/null
+++ b/js/dojo/dojox/wire/TableAdapter.js
@@ -0,0 +1,89 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/TableAdapter", ["dijit","dojo","dojox","dojo/require!dojox/wire/CompositeWire"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.TableAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TableAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for table rows
+ // description:
+ // This class has multiple child Wires for object properties or array
+ // elements of a table row.
+ // The root object for this class must be an array.
+ // When an object with Wires is specified to 'columns' property, they
+ // are used to get a row object with property values.
+ // When an array of Wires is specified to 'columns' property, they
+ // are used to get a row array with element values.
+ // The row values are returned in an array.
+ // This class only supports getValue(), but not setValue().
+
+ _wireClass: "dojox.wire.TableAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties or array elements specified in 'columns'
+ // property are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // columns:
+ // An object or array containing child Wires for column values
+ this._initializeChildren(this.columns);
+ },
+
+ _getValue: function(/*Array*/object){
+ // summary:
+ // Return an array of table row value (object or array)
+ // description:
+ // This method iterates over an array specified to 'object'
+ // argument and calls getValue() method of the child Wires with
+ // each element of the array to get a row object or array.
+ // Finally, an array with the row objects or arrays are retuned.
+ // object:
+ // A root array
+ // returns:
+ // An array of table row value
+ if(!object || !this.columns){
+ return object; //Array
+ }
+
+ var array = object;
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+
+ var rows = [];
+ for(var i in array){
+ var row = this._getRow(array[i]);
+ rows.push(row);
+ }
+ return rows; //Array
+ },
+
+ _setValue: function(/*Array*/object, /*Array*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _getRow: function(/*Object||Array*/object){
+ // summary:
+ // Return an array or object for a table row
+ // description:
+ // This method calls getValue() method of the child Wires to
+ // create a row object or array.
+ // returns:
+ // An array or object for a table row
+ var row = (dojo.isArray(this.columns) ? [] : {}); // array or object
+ for(var c in this.columns){
+ row[c] = this.columns[c].getValue(object);
+ }
+ return row; //Array||Object
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/TextAdapter.js b/js/dojo/dojox/wire/TextAdapter.js
new file mode 100644
index 0000000..0259c3d
--- /dev/null
+++ b/js/dojo/dojox/wire/TextAdapter.js
@@ -0,0 +1,89 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/TextAdapter", ["dijit","dojo","dojox","dojo/require!dojox/wire/CompositeWire"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.TextAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TextAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for a concatenated text
+ // description:
+ // This class has multiple child Wires for text segment values.
+ // Wires in 'segments' property are used to get text segments and
+ // values are concatenated with an optional delimiter string specified
+ // to 'delimiter' property.
+
+ _wireClass: "dojox.wire.TextAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If array elements specified in 'segments' are not Wires, Wires
+ // are created from them as arguments, with 'parent' property set
+ // to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // segments:
+ // An array containing child Wires for text segment values
+ // delimiter:
+ // A delimiter string
+ this._initializeChildren(this.segments);
+ if(!this.delimiter){
+ this.delimiter = "";
+ }
+ },
+
+ _getValue: function(/*Object||Array*/object){
+ // summary:
+ // Return a concatenated text
+ // description:
+ // This method calls getValue() method of the child Wires wuth
+ // 'object' argument and concatenate the values with 'delimiter'
+ // property to return.
+ // arg:
+ // A root object
+ // returns:
+ // A concatinated text
+ if(!object || !this.segments){
+ return object; //Object||Array
+ }
+
+ var text = "";
+ for(var i in this.segments){
+ var segment = this.segments[i].getValue(object);
+ text = this._addSegment(text, segment);
+ }
+ return text; //String
+ },
+
+ _setValue: function(/*Object||Array*/object, /*String*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _addSegment: function(/*String*/text, /*String*/segment){
+ // summary:
+ // Return a concatenated text
+ // description:
+ // This method add a text segment specified to 'segment' argument
+ // to a base text specified to 'text', with 'delimiter' property.
+ // text:
+ // A base text
+ // segment:
+ // A text segment to add
+ // returns:
+ // A concatinated text
+ if(!segment){
+ return text; //String
+ }else if(!text){
+ return segment; //String
+ }else{
+ return text + this.delimiter + segment; //String
+ }
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/TreeAdapter.js b/js/dojo/dojox/wire/TreeAdapter.js
new file mode 100644
index 0000000..d3be3b2
--- /dev/null
+++ b/js/dojo/dojox/wire/TreeAdapter.js
@@ -0,0 +1,189 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/TreeAdapter", ["dijit","dojo","dojox","dojo/require!dojox/wire/CompositeWire"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.TreeAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TreeAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for tree nodes
+ // description:
+ // This class has multiple child Wires for tree nodes, their title and
+ // child nodes.
+ // The root object for this class must be an array.
+ // 'node' Wires in 'nodes' property is used to identify an object
+ // representing a node.
+ // 'title' Wires in 'nodes' property is used to get the title string
+ // of a node.
+ // 'children' Wires in 'nodes' property is used to iterate over child
+ // node objects.
+ // The node values are returned in an array as follows:
+ // [
+ // {title: title1,
+ // children: [
+ // {title: title2,
+ // child: ...},
+ // {title: title3,
+ // child: ...},
+ // ...
+ // ]},
+ // ...
+ // ]
+ // This class only supports getValue(), but not setValue().
+
+ _wireClass: "dojox.wire.TreeAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties ('node', 'title' and 'children') of array
+ // elements specified in 'nodes' property are not Wires, Wires are
+ // created from them as arguments, with 'parent' property set to
+ // this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // nodes:
+ // An array containing objects for child Wires for node values
+ this._initializeChildren(this.nodes);
+ },
+ _getValue: function(/*Array*/object){
+ // summary:
+ // Return an array of tree node values
+ // description:
+ // This method iterates over an array specified to 'object'
+ // argument and calls getValue() method of 'node' Wires with each
+ // element of the array to get object(s) that represetns nodes.
+ // (If 'node' Wires are omitted, the array element is used for
+ // further processing.)
+ // Then, getValue() method of 'title' Wires are called to get
+ // title strings for nodes.
+ // (If 'title' Wires are omitted, the objects representing nodes
+ // are used as title strings.)
+ // And if an array of objects with 'node' and 'title' Wires is
+ // specified to 'children', it is used to gather child nodes and
+ // their title strings in the same way recursively.
+ // Finally, an array of the top-level node objects are retuned.
+ // object:
+ // A root array
+ // returns:
+ // An array of tree node values
+ if(!object || !this.nodes){
+ return object; //Array
+ }
+
+ var array = object;
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+
+ var nodes = [];
+ for(var i in array){
+ for(var i2 in this.nodes){
+ nodes = nodes.concat(this._getNodes(array[i], this.nodes[i2]));
+ }
+ }
+ return nodes; //Array
+ },
+
+ _setValue: function(/*Array*/object, /*Array*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _initializeChildren: function(/*Array*/children){
+ // summary:
+ // Initialize child Wires
+ // description:
+ // If 'node' or 'title' properties of array elements specified in
+ // 'children' argument are not Wires, Wires are created from them
+ // as arguments, with 'parent' property set to this Wire instance.
+ // If an array element has 'children' property, this method is
+ // called recursively with it.
+ // children:
+ // An array of objects containing child Wires
+ if(!children){
+ return; //undefined
+ }
+
+ for(var i in children){
+ var child = children[i];
+ if(child.node){
+ child.node.parent = this;
+ if(!dojox.wire.isWire(child.node)){
+ child.node = dojox.wire.create(child.node);
+ }
+ }
+ if(child.title){
+ child.title.parent = this;
+ if(!dojox.wire.isWire(child.title)){
+ child.title = dojox.wire.create(child.title);
+ }
+ }
+ if(child.children){
+ this._initializeChildren(child.children);
+ }
+ }
+ },
+
+ _getNodes: function(/*Object*/object, /*Object*/child){
+ // summary:
+ // Return an array of tree node values
+ // description:
+ // This method calls getValue() method of 'node' Wires with
+ // 'object' argument to get object(s) that represents nodes.
+ // (If 'node' Wires are omitted, 'object' is used for further
+ // processing.)
+ // Then, getValue() method of 'title' Wires are called to get
+ // title strings for nodes.
+ // (If 'title' Wires are omitted, the objects representing nodes
+ // are used as title strings.)
+ // And if an array of objects with 'node' and 'title' Wires is
+ // specified to 'children', it is used to gather child nodes and
+ // their title strings in the same way recursively.
+ // Finally, an array of node objects are returned.
+ // object:
+ // An object
+ // child:
+ // An object with child Wires
+ // returns:
+ var array = null;
+ if(child.node){
+ array = child.node.getValue(object);
+ if(!array){
+ return [];
+ }
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+ }else{
+ array = [object];
+ }
+
+ var nodes = [];
+ for(var i in array){
+ object = array[i];
+ var node = {};
+ if(child.title){
+ node.title = child.title.getValue(object);
+ }else{
+ node.title = object;
+ }
+ if(child.children){
+ var children = [];
+ for(var i2 in child.children){
+ children = children.concat(this._getNodes(object, child.children[i2]));
+ }
+ if(children.length > 0){
+ node.children = children;
+ }
+ }
+ nodes.push(node);
+ }
+ return nodes; //Array
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/Wire.js b/js/dojo/dojox/wire/Wire.js
new file mode 100644
index 0000000..75b11ec
--- /dev/null
+++ b/js/dojo/dojox/wire/Wire.js
@@ -0,0 +1,382 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/Wire", ["dijit","dojo","dojox","dojo/require!dojox/wire/_base"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.Wire");
+
+dojo.require("dojox.wire._base");
+
+dojo.declare("dojox.wire.Wire", null, {
+ // summary:
+ // A default and base Wire to access an object property
+ // description:
+ // This class accesses a property of an object with a dotted notation
+ // specified to 'property' property, such as "a.b.c", which identifies
+ // a descendant property, "object.a.b.c".
+ // Property names in the dotted notation may have an array index, such
+ // as "a[0]", to identify an array element, literally, "object.a[0]".
+ // When a notation start with an array index, such as "[0].a", it
+ // specifies an array element of the root object (array),
+ // "object[0].a".
+ // This class also serves as a base class for other Wire classes,
+ // preparing a root object and converting a return value, so that
+ // sub-classes just can implement _getValue() and _setValue() called
+ // from getValue() and setValue() implemented by this calss.
+
+ _wireClass: "dojox.wire.Wire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If 'converter' property is specified and is a string for
+ // a converter class, an instanceof the converter class is
+ // created.
+ // args:
+ // Arguments to initialize properties
+ // object:
+ // A root object (or another Wire to access a root object)
+ // property:
+ // A dotted notation to a descendant property
+ // type:
+ // A type of the return value (for the source Wire)
+ // converter:
+ // A converter object (or class name) to convert the return
+ // value (for the source Wire)
+ dojo.mixin(this, args);
+
+ if(this.converter){
+ if(dojo.isString(this.converter)){
+ //First check the object tree for it. Might be defined variable
+ //name/global function (like a jsId, or just a function name).
+ var convertObject = dojo.getObject(this.converter);
+ if(dojo.isFunction(convertObject)){
+ //We need to see if this is a pure function or an object constructor...
+ try{
+ var testObj = new convertObject();
+ if(testObj && !dojo.isFunction(testObj["convert"])){
+ //Looks like a 'pure' function...
+ this.converter = {convert: convertObject};
+ }else{
+ this.converter = testObj;
+ }
+ }catch(e){
+ //Do if this fails.
+ }
+ }else if(dojo.isObject(convertObject)){
+ //It's an object, like a jsId ... see if it has a convert function
+ if(dojo.isFunction(convertObject["convert"])){
+ this.converter = convertObject;
+ }
+ }
+
+ //No object with that name (Converter is still a string),
+ //then look for a class that needs to be dynamically loaded...
+ if(dojo.isString(this.converter)){
+ var converterClass = dojox.wire._getClass(this.converter);
+ if(converterClass){
+ this.converter = new converterClass();
+ }else{
+ this.converter = undefined;
+ }
+ }
+ }else if(dojo.isFunction(this.converter)){
+ this.converter = {convert: this.converter};
+ }
+ }
+ },
+
+ getValue: function(/*Object||Array*/defaultObject){
+ // summary:
+ // Return a value of an object
+ // description:
+ // This method first determins a root object as follows:
+ // 1. If 'object' property specified,
+ // 1.1 If 'object' is a Wire, its getValue() method is called to
+ // obtain a root object.
+ // 1.2 Otherwise, use 'object' as a root object.
+ // 2. Otherwise, use 'defaultObject' argument.
+ // 3. If 'property' is specified, it is used to get a property
+ // value.
+ // Then, if a sub-class implements _getValue() method, it is
+ // called with the root object to get the return value.
+ // Otherwise, the root object (typically, a property valye) is
+ // used for the return value.
+ // Finally, if 'type' property is specified, the return value is
+ // converted to the specified primitive type ("string", "number",
+ // "boolean" and "array").
+ // If 'converter' property is specified, its convert() method is
+ // called to convert the value.
+ // defaultObject:
+ // A default root object
+ // returns:
+ // A value found
+ var object = undefined;
+ if(dojox.wire.isWire(this.object)){
+ object = this.object.getValue(defaultObject);
+ }else{
+ object = (this.object || defaultObject);
+ }
+
+ if(this.property){
+ var list = this.property.split('.');
+ for(var i in list){
+ if(!object){
+ return object; //anything (null, undefined, etc)
+ }
+ object = this._getPropertyValue(object, list[i]);
+ }
+ }
+
+ var value = undefined;
+ if(this._getValue){
+ value = this._getValue(object);
+ }else{
+ value = object;
+ }
+
+ if(value){
+ if(this.type){
+ if(this.type == "string"){
+ value = value.toString();
+ }else if(this.type == "number"){
+ value = parseInt(value, 10);
+ }else if(this.type == "boolean"){
+ value = (value != "false");
+ }else if(this.type == "array"){
+ if(!dojo.isArray(value)){
+ value = [value];
+ }
+ }
+ }
+ if(this.converter && this.converter.convert){
+ value = this.converter.convert(value, this); // optional "this" context
+ }
+ }
+ return value; //anything
+ },
+
+ setValue: function(/*anything*/value, /*Object||Array*/defaultObject){
+ // summary:
+ // Set a value to an object
+ // description:
+ // This method first determins a root object as follows:
+ // 1. If 'object' property specified,
+ // 1.1 If 'object' is a Wire, its getValue() method is called to
+ // obtain a root object.
+ // 1.2 Otherwise, use 'object' as a root object.
+ // 2. Otherwise, use 'defaultObject' argument.
+ // 3. If 'property' is specified, it is used to get a property
+ // value.
+ // Then, if a sub-class implements _setValue() method, it is
+ // called with the root object and 'value' argument to set
+ // the value.
+ // Otherwise, 'value' is set to a property specified with
+ // 'property' property.
+ // If the root object is undefined and 'object' property is a Wire
+ // and a new object is created and returned by _setValue() it is
+ // set through 'object' (setValue() method).
+ // value:
+ // A value to set
+ // defaultObject:
+ // A default root object
+ var object = undefined;
+ if(dojox.wire.isWire(this.object)){
+ object = this.object.getValue(defaultObject);
+ }else{
+ object = (this.object || defaultObject);
+ }
+
+ var property = undefined;
+ var o;
+ if(this.property){
+ if(!object){
+ if(dojox.wire.isWire(this.object)){
+ object = {};
+ this.object.setValue(object, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid object");
+ }
+ }
+ var list = this.property.split('.');
+ var last = list.length - 1;
+ for(var i = 0; i < last; i++){
+ var p = list[i];
+ o = this._getPropertyValue(object, p);
+ if(!o){
+ o = {};
+ this._setPropertyValue(object, p, o);
+ }
+ object = o;
+ }
+ property = list[last];
+ }
+
+ if(this._setValue){
+ if(property){
+ o = this._getPropertyValue(object, property);
+ if(!o){
+ o = {};
+ this._setPropertyValue(object, property, o);
+ }
+ object = o;
+ }
+ var newObject = this._setValue(object, value);
+ if(!object && newObject){
+ if(dojox.wire.isWire(this.object)){
+ this.object.setValue(newObject, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid object");
+ }
+ }
+ }else{
+ if(property){
+ this._setPropertyValue(object, property, value);
+ }else{
+ if(dojox.wire.isWire(this.object)){
+ this.object.setValue(value, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid property");
+ }
+ }
+ }
+ },
+
+ _getPropertyValue: function(/*Object||Array*/object, /*String*/property){
+ // summary:
+ // Return a property value of an object
+ // description:
+ // A value for 'property' of 'object' is returned.
+ // If 'property' ends with an array index, it is used to indentify
+ // an element of an array property.
+ // If 'object' implements getPropertyValue(), it is called with
+ // 'property' to obtain the property value.
+ // If 'object' implements a getter for the property, it is called
+ // to obtain the property value.
+ // object:
+ // A default root object
+ // property:
+ // A property name
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ var i1 = property.indexOf('[');
+ if(i1 >= 0){
+ var i2 = property.indexOf(']');
+ var index = property.substring(i1 + 1, i2);
+ var array = null;
+ if(i1 === 0){ // object is array
+ array = object;
+ }else{
+ property = property.substring(0, i1);
+ array = this._getPropertyValue(object, property);
+ if(array && !dojo.isArray(array)){
+ array = [array];
+ }
+ }
+ if(array){
+ value = array[index];
+ }
+ }else if(object.getPropertyValue){
+ value = object.getPropertyValue(property);
+ }else{
+ var getter = "get" + property.charAt(0).toUpperCase() + property.substring(1);
+ if(this._useGet(object)){
+ value = object.get(property);
+ }else if(this._useAttr(object)){
+ value = object.attr(property);
+ } else if(object[getter]){
+ value = object[getter]();
+ }else{
+ value = object[property];
+ }
+ }
+ return value; //anything
+ },
+
+ _setPropertyValue: function(/*Object||Array*/object, /*String*/property, /*anything*/value){
+ // summary:
+ // Set a property value to an object
+ // description:
+ // 'value' is set to 'property' of 'object'.
+ // If 'property' ends with an array index, it is used to indentify
+ // an element of an array property to set the value.
+ // If 'object' implements setPropertyValue(), it is called with
+ // 'property' and 'value' to set the property value.
+ // If 'object' implements a setter for the property, it is called
+ // with 'value' to set the property value.
+ // object:
+ // An object
+ // property:
+ // A property name
+ // value:
+ // A value to set
+ var i1 = property.indexOf('[');
+ if(i1 >= 0){
+ var i2 = property.indexOf(']');
+ var index = property.substring(i1 + 1, i2);
+ var array = null;
+ if(i1 === 0){ // object is array
+ array = object;
+ }else{
+ property = property.substring(0, i1);
+ array = this._getPropertyValue(object, property);
+ if(!array){
+ array = [];
+ this._setPropertyValue(object, property, array);
+ }
+ }
+ array[index] = value;
+ }else if(object.setPropertyValue){
+ object.setPropertyValue(property, value);
+ }else{
+ var setter = "set" + property.charAt(0).toUpperCase() + property.substring(1);
+ if(this._useSet(object)){
+ object.set(property, value);
+ }else if(this._useAttr(object)){
+ object.attr(property, value);
+ }else if(object[setter]){
+ object[setter](value);
+ }else{
+ object[property] = value;
+ }
+ }
+ },
+
+ _useGet: function(object){
+ // summary:
+ // Function to detect if dijit.get support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useGet = false;
+ if(dojo.isFunction(object.get)){
+ useGet = true;
+ }
+ return useGet;
+ },
+
+ _useSet: function(object){
+ // summary:
+ // Function to detect if dijit.set support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useSet = false;
+ if(dojo.isFunction(object.set)){
+ useSet = true;
+ }
+ return useSet;
+ },
+
+ _useAttr: function(object){
+ // summary:
+ // Function to detect if dijit.attr support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useAttr = false;
+ if(dojo.isFunction(object.attr)){
+ useAttr = true;
+ }
+ return useAttr;
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/XmlWire.js b/js/dojo/dojox/wire/XmlWire.js
new file mode 100644
index 0000000..583f367
--- /dev/null
+++ b/js/dojo/dojox/wire/XmlWire.js
@@ -0,0 +1,247 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/XmlWire", ["dijit","dojo","dojox","dojo/require!dojox/xml/parser,dojox/wire/Wire"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.XmlWire");
+
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.XmlWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for XML nodes or values (element, attribute and text)
+ // description:
+ // This class accesses XML nodes or value with a simplified XPath
+ // specified to 'path' property.
+ // The root object for this class must be an DOM document or element
+ // node.
+ // "@name" accesses to an attribute value of an element and "text()"
+ // accesses to a text value of an element.
+ // The hierarchy of the elements from the root node can be specified
+ // with slash-separated list, such as "a/b/@c", which specifies
+ // the value of an attribute named "c" of an element named "b" as
+ // a child of another element named "a" of a child of the root node.
+
+ _wireClass: "dojox.wire.XmlWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // 'args' is just mixed in with no further processing.
+ // args:
+ // Arguments to initialize properties
+ // path:
+ // A simplified XPath to an attribute, a text or elements
+ },
+ _getValue: function(/*Node*/object){
+ // summary:
+ // Return an attribute value, a text value or an array of elements
+ // description:
+ // This method first uses a root node passed in 'object' argument
+ // and 'path' property to identify an attribute, a text or
+ // elements.
+ // If 'path' starts with a slash (absolute), the first path
+ // segment is ignored assuming it point to the root node.
+ // (That is, "/a/b/@c" and "b/@c" against a root node access
+ // the same attribute value, assuming the root node is an element
+ // with a tag name, "a".)
+ // object:
+ // A root node
+ // returns:
+ // A value found, otherwise 'undefined'
+ if(!object || !this.path){
+ return object; //Node
+ }
+
+ var node = object;
+ var path = this.path;
+ var i;
+ if(path.charAt(0) == '/'){ // absolute
+ // skip the first expression (supposed to select the top node)
+ i = path.indexOf('/', 1);
+ path = path.substring(i + 1);
+ }
+ var list = path.split('/');
+ var last = list.length - 1;
+ for(i = 0; i < last; i++){
+ node = this._getChildNode(node, list[i]);
+ if(!node){
+ return undefined; //undefined
+ }
+ }
+ var value = this._getNodeValue(node, list[last]);
+ return value; //String||Array
+ },
+
+ _setValue: function(/*Node*/object, /*String*/value){
+ // summary:
+ // Set an attribute value or a child text value to an element
+ // description:
+ // This method first uses a root node passed in 'object' argument
+ // and 'path' property to identify an attribute, a text or
+ // elements.
+ // If an intermediate element does not exist, it creates
+ // an element of the tag name in the 'path' segment as a child
+ // node of the current node.
+ // Finally, 'value' argument is set to an attribute or a text
+ // (a child node) of the leaf element.
+ // object:
+ // A root node
+ // value:
+ // A value to set
+ if(!this.path){
+ return object; //Node
+ }
+
+ var node = object;
+ var doc = this._getDocument(node);
+ var path = this.path;
+ var i;
+ if(path.charAt(0) == '/'){ // absolute
+ i = path.indexOf('/', 1);
+ if(!node){
+ var name = path.substring(1, i);
+ node = doc.createElement(name);
+ object = node; // to be returned as a new object
+ }
+ // skip the first expression (supposed to select the top node)
+ path = path.substring(i + 1);
+ }else{
+ if(!node){
+ return undefined; //undefined
+ }
+ }
+
+ var list = path.split('/');
+ var last = list.length - 1;
+ for(i = 0; i < last; i++){
+ var child = this._getChildNode(node, list[i]);
+ if(!child){
+ child = doc.createElement(list[i]);
+ node.appendChild(child);
+ }
+ node = child;
+ }
+ this._setNodeValue(node, list[last], value);
+ return object; //Node
+ },
+
+ _getNodeValue: function(/*Node*/node, /*String*/exp){
+ // summary:
+ // Return an attribute value, a text value or an array of elements
+ // description:
+ // If 'exp' starts with '@', an attribute value of the specified
+ // attribute is returned.
+ // If 'exp' is "text()", a child text value is returned.
+ // Otherwise, an array of child elements, the tag name of which
+ // match 'exp', is returned.
+ // node:
+ // A node
+ // exp:
+ // An expression for attribute, text or elements
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ if(exp.charAt(0) == '@'){
+ var attribute = exp.substring(1);
+ value = node.getAttribute(attribute);
+ }else if(exp == "text()"){
+ var text = node.firstChild;
+ if(text){
+ value = text.nodeValue;
+ }
+ }else{ // assume elements
+ value = [];
+ for(var i = 0; i < node.childNodes.length; i++){
+ var child = node.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == exp){
+ value.push(child);
+ }
+ }
+ }
+ return value; //String||Array
+ },
+
+ _setNodeValue: function(/*Node*/node, /*String*/exp, /*String*/value){
+ // summary:
+ // Set an attribute value or a child text value to an element
+ // description:
+ // If 'exp' starts with '@', 'value' is set to the specified
+ // attribute.
+ // If 'exp' is "text()", 'value' is set to a child text.
+ // node:
+ // A node
+ // exp:
+ // An expression for attribute or text
+ // value:
+ // A value to set
+ if(exp.charAt(0) == '@'){
+ var attribute = exp.substring(1);
+ if(value){
+ node.setAttribute(attribute, value);
+ }else{
+ node.removeAttribute(attribute);
+ }
+ }else if(exp == "text()"){
+ while(node.firstChild){
+ node.removeChild(node.firstChild);
+ }
+ if(value){
+ var text = this._getDocument(node).createTextNode(value);
+ node.appendChild(text);
+ }
+ }
+ // else not supported
+ },
+
+ _getChildNode: function(/*Node*/node, /*String*/name){
+ // summary:
+ // Return a child node
+ // description:
+ // A child element of the tag name specified with 'name' is
+ // returned.
+ // If 'name' ends with an array index, it is used to pick up
+ // the corresponding element from multiple child elements.
+ // node:
+ // A parent node
+ // name:
+ // A tag name
+ // returns:
+ // A child node
+ var index = 1;
+ var i1 = name.indexOf('[');
+ if(i1 >= 0){
+ var i2 = name.indexOf(']');
+ index = name.substring(i1 + 1, i2);
+ name = name.substring(0, i1);
+ }
+ var count = 1;
+ for(var i = 0; i < node.childNodes.length; i++){
+ var child = node.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == name){
+ if(count == index){
+ return child; //Node
+ }
+ count++;
+ }
+ }
+ return null; //null
+ },
+
+ _getDocument: function(/*Node*/node){
+ // summary:
+ // Return a DOM document
+ // description:
+ // If 'node' is specified, a DOM document of the node is returned.
+ // Otherwise, a DOM document is created.
+ // returns:
+ // A DOM document
+ if(node){
+ return (node.nodeType == 9 /* DOCUMENT_NODE */ ? node : node.ownerDocument); //Document
+ }else{
+ return dojox.xml.parser.parse(); //Document
+ }
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/_base.js b/js/dojo/dojox/wire/_base.js
new file mode 100644
index 0000000..66a7260
--- /dev/null
+++ b/js/dojo/dojox/wire/_base.js
@@ -0,0 +1,196 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/_base", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire._base");
+
+dojox.wire._defaultWireClass = "dojox.wire.Wire";
+
+dojox.wire._wireClasses = {
+ "attribute": "dojox.wire.DataWire",
+ "path": "dojox.wire.XmlWire",
+ "children": "dojox.wire.CompositeWire",
+ "columns": "dojox.wire.TableAdapter",
+ "nodes": "dojox.wire.TreeAdapter",
+ "segments": "dojox.wire.TextAdapter"
+};
+
+dojox.wire.register = function(/*Function||String*/wireClass, /*String*/key){
+ // summary:
+ // Register a Wire class
+ // desription:
+ // The specified Wire class or a class name is registered with
+ // a key property of arguments to create a Wire
+ // wireClass:
+ // A class or full qualified class name
+ // key:
+ // A key property of arguments to create a Wire
+ if(!wireClass || !key){
+ return; //undefined
+ }
+ if(dojox.wire._wireClasses[key]){ // key already in use
+ return; //undefined
+ }
+ dojox.wire._wireClasses[key] = wireClass;
+};
+
+dojox.wire._getClass = function(/*String*/name){
+ // summary:
+ // Returns a class
+ // description:
+ // The class is loaded by dojo.require() and returned
+ // by dojo.getObject().
+ // name:
+ // A class name
+ // returns:
+ // A class
+ dojo["require"](name); // use dojo["require"] instead of dojo.require to avoid a build problem
+ return dojo.getObject(name); //Function
+};
+
+dojox.wire.create = function(/*Object*/args){
+ // summary:
+ // Create a Wire from arguments
+ // description:
+ // If 'args' specifies 'wireClass', it is used as a class or full
+ // qualified class name to create a Wire with 'args' as arguments.
+ // Otherwise, a Wire class is determined by other proeprties of 'args'
+ // checking if 'args' specifies a key property for a Wire class.
+ // If no key property found, the default Wire class is used.
+ // args:
+ // Arguments to create a Wire
+ // returns:
+ // A Wire
+ if(!args){
+ args = {};
+ }
+ var wireClass = args.wireClass;
+ if(wireClass){
+ if(dojo.isString(wireClass)){
+ wireClass = dojox.wire._getClass(wireClass);
+ }
+ }else{
+ for(var key in args){
+ if(!args[key]){
+ continue;
+ }
+ wireClass = dojox.wire._wireClasses[key];
+ if(wireClass){
+ if(dojo.isString(wireClass)){
+ wireClass = dojox.wire._getClass(wireClass);
+ dojox.wire._wireClasses[key] = wireClass;
+ }
+ break;
+ }
+ }
+ }
+ if(!wireClass){
+ if(dojo.isString(dojox.wire._defaultWireClass)){
+ dojox.wire._defaultWireClass = dojox.wire._getClass(dojox.wire._defaultWireClass);
+ }
+ wireClass = dojox.wire._defaultWireClass;
+ }
+ return new wireClass(args); //Object
+};
+
+dojox.wire.isWire = function(/*Object*/wire){
+ // summary:
+ // Check if an object is a Wire
+ // description:
+ // If the specified object is a Wire, true is returned.
+ // Otherwise, false is returned.
+ // wire:
+ // An object to check
+ // returns:
+ // True if the object is a Wire, otherwise false
+ return (wire && wire._wireClass); //Boolean
+};
+
+dojox.wire.transfer = function(/*Wire||Object*/source, /*Wire||Object*/target, /*Object?*/defaultObject, /*Object?*/defaultTargetObject){
+ // summary:
+ // Transfer a source value to a target value
+ // description:
+ // If 'source' and/or 'target' are not Wires, Wires are created with
+ // them as arguments.
+ // A value is got through the source Wire and set through the target
+ // Wire.
+ // 'defaultObject' is passed to Wires as a default root object.
+ // If 'defaultTargetObject' is specified, it is passed to the target
+ // Wire as a default root object, instead of 'defaultObject'.
+ // source:
+ // A Wire or arguments to create a Wire for a source value
+ // target:
+ // A Wire or arguments to create a Wire for a target value
+ // defaultObject:
+ // defaultTargetObject;
+ // Optional default root objects passed to Wires
+ if(!source || !target){
+ return; //undefined
+ }
+ if(!dojox.wire.isWire(source)){
+ source = dojox.wire.create(source);
+ }
+ if(!dojox.wire.isWire(target)){
+ target = dojox.wire.create(target);
+ }
+
+ var value = source.getValue(defaultObject);
+ target.setValue(value, (defaultTargetObject || defaultObject));
+};
+
+dojox.wire.connect = function(/*Object*/trigger, /*Wire||Object*/source, /*Wire||Object*/target){
+ // summary:
+ // Transfer a source value to a target value on a trigger event or
+ // topic
+ // description:
+ // If 'trigger' specifies 'topic', the topic is subscribed to transer
+ // a value on the topic.
+ // Otherwise, the event specified to 'event' of 'trigger' is listened
+ // to transfer a value.
+ // On the specified event or topic, transfer() is called with
+ // 'source', 'target' and the arguments of the event or topic (as
+ // default root objects).
+ // trigger:
+ // An event or topic to trigger a transfer
+ // source:
+ // A Wire or arguments to create a Wire for a source value
+ // target:
+ // A Wire or arguments to create a Wire for a target value
+ // returns:
+ // A connection handle for disconnect()
+ if(!trigger || !source || !target){
+ return; //undefined
+ }
+
+ var connection = {topic: trigger.topic};
+ if(trigger.topic){
+ connection.handle = dojo.subscribe(trigger.topic, function(){
+ dojox.wire.transfer(source, target, arguments);
+ });
+ }else if(trigger.event){
+ connection.handle = dojo.connect(trigger.scope, trigger.event, function(){
+ dojox.wire.transfer(source, target, arguments);
+ });
+ }
+ return connection; //Object
+};
+
+dojox.wire.disconnect = function(/*Object*/connection){
+ // summary:
+ // Remove a connection or subscription for transfer
+ // description:
+ // If 'handle' has 'topic', the topic is unsubscribed.
+ // Otherwise, the listener to an event is removed.
+ // connection:
+ // A connection handle returned by connect()
+ if(!connection || !connection.handle){
+ return; //undefined
+ }
+
+ if(connection.topic){
+ dojo.unsubscribe(connection.handle);
+ }else{
+ dojo.disconnect(connection.handle);
+ }
+};
+
+});
diff --git a/js/dojo/dojox/wire/demos/TableContainer.css b/js/dojo/dojox/wire/demos/TableContainer.css
new file mode 100644
index 0000000..4ee2706
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/TableContainer.css
@@ -0,0 +1,30 @@
+.tablecontainer {
+ padding: 3 3 3 3;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #000000;
+ border-collapse: separate;
+}
+
+.tablecontainer th {
+ text-align: left;
+}
+
+.tablecontainer tr {
+ padding: 3 3 3 3;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #000000;
+}
+
+.tablecontainer tr td {
+ padding: 3 3 3 3;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #000000;
+}
+
+.alternate {
+ background-color: #EEEEEE;
+}
+
diff --git a/js/dojo/dojox/wire/demos/TableContainer.js b/js/dojo/dojox/wire/demos/TableContainer.js
new file mode 100644
index 0000000..a74b57d
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/TableContainer.js
@@ -0,0 +1,69 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/demos/TableContainer", ["dijit","dojo","dojox","dojo/require!dojo/parser,dijit/_Widget,dijit/_Templated"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.demos.TableContainer");
+
+dojo.require("dojo.parser");
+dojo.require("dijit._Widget");
+dojo.require("dijit._Templated");
+
+dojo.declare("dojox.wire.demos.TableContainer", [ dijit._Widget, dijit._Templated, dijit._Container ], {
+ // summary:
+ // Extremely simple 'widget' that is a table generator with an addRow function that takes an array
+ // as the row to add, where each entry is a cell in the row. This demo widget is for use with the
+ // wire demos.
+
+ templateString: "<table class='tablecontainer'><tbody dojoAttachPoint='tableContainer'></tbody></table>",
+ rowCount: 0,
+ headers: "",
+ addRow: function(array){
+ // summary:
+ // Function to add in a new row from the elements in the array map to cells in the row.
+ // array:
+ // Array of row values to add.
+ try{
+ var row = document.createElement("tr");
+ if((this.rowCount%2) === 0){
+ dojo.addClass(row, "alternate");
+ }
+ this.rowCount++;
+ for(var i in array){
+ var cell = document.createElement("td");
+ var text = document.createTextNode(array[i]);
+ cell.appendChild(text);
+ row.appendChild(cell);
+
+ }
+ this.tableContainer.appendChild(row);
+ }catch(e){ console.debug(e); }
+ },
+
+ clearTable: function(){
+ // summary:
+ // Function to clear all the current rows in the table, except for the header.
+
+ //Always leave the first row, which is the table header.
+ while(this.tableContainer.firstChild.nextSibling){
+ this.tableContainer.removeChild(this.tableContainer.firstChild.nextSibling);
+ }
+ this.rowCount = 0;
+ },
+
+ postCreate: function(){
+ // summary:
+ // Widget lifecycle function to handle generation of the header elements in the table.
+ var headers = this.headers.split(",");
+ var tr = document.createElement("tr");
+ for(i in headers){
+
+ var header = headers[i];
+ var th = document.createElement("th");
+ var text = document.createTextNode(header);
+ th.appendChild(text);
+ tr.appendChild(th);
+ }
+ this.tableContainer.appendChild(tr);
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/demos/WidgetRepeater.js b/js/dojo/dojox/wire/demos/WidgetRepeater.js
new file mode 100644
index 0000000..2fb7d67
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/WidgetRepeater.js
@@ -0,0 +1,34 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/demos/WidgetRepeater", ["dijit","dojo","dojox","dojo/require!dojo/parser,dijit/_Widget,dijit/_Templated,dijit/_Container"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.demos.WidgetRepeater")
+
+dojo.require("dojo.parser");
+dojo.require("dijit._Widget");
+dojo.require("dijit._Templated");
+dojo.require("dijit._Container");
+
+dojo.declare("dojox.wire.demos.WidgetRepeater", [ dijit._Widget, dijit._Templated, dijit._Container ], {
+ // summary:
+ // Simple widget that does generation of widgets repetatively, based on calls to
+ // the createNew function and contains them as child widgets.
+ templateString: "<div class='WidgetRepeater' dojoAttachPoint='repeaterNode'></div>",
+ widget: null,
+ repeater: null,
+ createNew: function(obj){
+ // summary:
+ // Function to handle the creation of a new widget and appending it into the widget tree.
+ // obj:
+ // The parameters to pass to the widget.
+ try{
+ if(dojo.isString(this.widget)){
+ // dojo.require(this.widget); confuses new AMD builder, include resource manually first
+ this.widget = dojo.getObject(this.widget);
+ }
+ this.addChild(new this.widget(obj));
+ this.repeaterNode.appendChild(document.createElement("br"));
+ }catch(e){ console.debug(e); }
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/demos/markup/countries.json b/js/dojo/dojox/wire/demos/markup/countries.json
new file mode 100644
index 0000000..ad3a07a
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/countries.json
@@ -0,0 +1,43 @@
+{ identifier: 'name',
+ items: [
+ { name:'Africa', type:'continent',
+ children:[{_reference:'Egypt'}, {_reference:'Kenya'}, {_reference:'Sudan'}] },
+ { name:'Egypt', type:'country' },
+ { name:'Kenya', type:'country',
+ children:[{_reference:'Nairobi'}, {_reference:'Mombasa'}] },
+ { name:'Nairobi', type:'city' },
+ { name:'Mombasa', type:'city' },
+ { name:'Sudan', type:'country',
+ children:{_reference:'Khartoum'} },
+ { name:'Khartoum', type:'city' },
+ { name:'Asia', type:'continent',
+ children:[{_reference:'China'}, {_reference:'India'}, {_reference:'Russia'}, {_reference:'Mongolia'}] },
+ { name:'China', type:'country' },
+ { name:'India', type:'country' },
+ { name:'Russia', type:'country' },
+ { name:'Mongolia', type:'country' },
+ { name:'Australia', type:'continent', population:'21 million',
+ children:{_reference:'Commonwealth of Australia'}},
+ { name:'Commonwealth of Australia', type:'country', population:'21 million'},
+ { name:'Europe', type:'continent',
+ children:[{_reference:'Germany'}, {_reference:'France'}, {_reference:'Spain'}, {_reference:'Italy'}] },
+ { name:'Germany', type:'country' },
+ { name:'France', type:'country' },
+ { name:'Spain', type:'country' },
+ { name:'Italy', type:'country' },
+ { name:'North America', type:'continent',
+ children:[{_reference:'Mexico'}, {_reference:'Canada'}, {_reference:'United States of America'}] },
+ { name:'Mexico', type:'country', population:'108 million', area:'1,972,550 sq km',
+ children:[{_reference:'Mexico City'}, {_reference:'Guadalajara'}] },
+ { name:'Mexico City', type:'city', population:'19 million', timezone:'-6 UTC'},
+ { name:'Guadalajara', type:'city', population:'4 million', timezone:'-6 UTC' },
+ { name:'Canada', type:'country', population:'33 million', area:'9,984,670 sq km',
+ children:[{_reference:'Ottawa'}, {_reference:'Toronto'}] },
+ { name:'Ottawa', type:'city', population:'0.9 million', timezone:'-5 UTC'},
+ { name:'Toronto', type:'city', population:'2.5 million', timezone:'-5 UTC' },
+ { name:'United States of America', type:'country' },
+ { name:'South America', type:'continent',
+ children:[{_reference:'Brazil'}, {_reference:'Argentina'}] },
+ { name:'Brazil', type:'country', population:'186 million' },
+ { name:'Argentina', type:'country', population:'40 million' }
+]}
diff --git a/js/dojo/dojox/wire/demos/markup/demo_ActionChaining.html b/js/dojo/dojox/wire/demos/markup/demo_ActionChaining.html
new file mode 100644
index 0000000..bba408a
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/demo_ActionChaining.html
@@ -0,0 +1,112 @@
+<!--
+ This file demonstrates how the dojox.wire code can be used to do declarative
+ wiring of events. Specifically, it shows how you can chain actions together
+ in a sequence. In this case the setting of a value on one textbox triggers a
+ copy over to another textbox. That in turn triggers yet another copy to another
+ text box.
+-->
+<html>
+<head>
+ <title>Sample Action Chaining</title>
+ <style type="text/css">
+
+ @import "../../../../dijit/themes/tundra/tundra.css";
+ @import "../../../../dojo/resources/dojo.css";
+ @import "../../../../dijit/tests/css/dijitTests.css";
+ @import "../TableContainer.css";
+
+ .splitView {
+ width: 90%;
+ height: 90%;
+ border: 1px solid #bfbfbf;
+ border-collapse: separate;
+ }
+ </style>
+
+ <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dojox.wire");
+ dojo.require("dojox.wire.ml.Invocation");
+ dojo.require("dojox.wire.ml.DataStore");
+ dojo.require("dojox.wire.ml.Transfer");
+ dojo.require("dojox.wire.ml.Data");
+ dojo.require("dijit.form.TextBox");
+ </script>
+</head>
+
+<body class="tundra">
+
+ <!-- Layout -->
+ <font size="3"><b>Demo of Chaining Actions:</b></font><br/><br/>
+ This demo shows how you can chain actions together to fire in a sequence.
+ Such as the completion of setting one value on a widget triggers the setting of another value on the widget
+ <br/>
+ <br/>
+ <table>
+ <tr>
+ <td>
+ <div dojoType="dijit.form.TextBox" id="inputField" value="" size="50" intermediateChanges="true"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div dojoType="dijit.form.TextBox" id="targetField1" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div dojoType="dijit.form.TextBox" id="targetField2" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ </table>
+
+
+ <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
+
+ <!--
+ This is an example of using the declarative data value definition.
+ These are effectively declarative variables to act as placeholders
+ for data values.
+ -->
+ <div dojoType="dojox.wire.ml.Data"
+ id="data">
+ <div dojoType="dojox.wire.ml.DataProperty"
+ name="tempData"
+ value="">
+ </div>
+ <div dojoType="dojox.wire.ml.DataProperty"
+ name="value"
+ value="value">
+ </div>
+ </div>
+
+ <!--
+ Whenever a key is entered into the textbox, copy the value somewhere, then invoke a method on another widget, in this case
+ on just another text box.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ id="action1"
+ trigger="inputField"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.Transfer" source="inputField.value" target="data.tempData"></div>
+ <div dojoType="dojox.wire.ml.Invocation" id="targetCopy" object="targetField1" method="set" parameters="data.value, data.tempData"></div>
+ </div>
+
+ <!--
+ Whenever the primary cloning invocation completes, invoke a secondary cloning action.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ id="action2"
+ trigger="targetCopy"
+ triggerEvent="onComplete">
+ <!--
+ Note that this uses the basic 'property' form of copying the property over and setting it. The Wire
+ code supports both getX and setX functions of setting a property as well as direct access. It first looks
+ for the getX/setX functions and if present, uses them. If missing, it will just do direct access. Because
+ of the standard getValue/setValue API of dijit form widgets, these transfers work really well and are very compact.
+ -->
+ <div dojoType="dojox.wire.ml.Transfer" source="targetField1.value" target="targetField2.value"></div>
+ </div>
+</body>
+</html>
diff --git a/js/dojo/dojox/wire/demos/markup/demo_ActionWiring.html b/js/dojo/dojox/wire/demos/markup/demo_ActionWiring.html
new file mode 100644
index 0000000..3f57a74
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/demo_ActionWiring.html
@@ -0,0 +1,138 @@
+<!--
+ This file demonstrates how the dojox.wire code can be used to do declarative
+ wiring of events on one item to trigger event on other widgets. It also shows
+ how you can use the Transfer object to morph data values from one format to
+ another. In this specific case, it maps the values from a dojo.data Datastore
+ item into values stored in a JavaScript Array, which is the format required for
+ the addRow method of the demonstration TableContainer.
+
+ Note that this demo expects dojo, digit, and dojox to all be peers in the same directory
+ in order for it to execute.
+-->
+<html>
+<head>
+ <title>Sample declarative data binding</title>
+ <style type="text/css">
+
+ @import "../../../../dojo/resources/dojo.css";
+ @import "../../../../dijit/themes/soria/soria.css";
+ @import "../../../../dijit/tests/css/dijitTests.css";
+ @import "../TableContainer.css";
+
+ .splitView {
+ width: 90%;
+ height: 90%;
+ overflow: hidden;
+ }
+ </style>
+
+ <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dojox.wire.ml.Invocation");
+ dojo.require("dojox.wire.ml.DataStore");
+ dojo.require("dojox.wire.ml.Transfer");
+
+ dojo.require("dijit.layout.BorderContainer");
+ dojo.require("dijit.layout.ContentPane");
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.TextBox");
+
+ dojo.require("dojo.data.ItemFileReadStore");
+ dojo.require("dojox.wire");
+ dojo.require("dojox.wire.demos.TableContainer");
+
+ //Toplevel JS Object to contain a few basics for us, such as the request to pass to the store and a stub onItem function
+ // to trap on for triggering other events.
+ dataHolder = {
+ //Simple object definition to get all items and sort it by the attribute 'type'.
+ request: {query: {name: "*"}, onItem: function(item, req){}, sort: [{attribute: "type"}]},
+ //Spot to store off data values as they're generated by the declarative binding.
+ result: null
+ };
+
+ </script>
+</head>
+
+<body class="soria">
+
+ <!-- The following is the basic layout. A split container with a button and a text field. Data will be displayed on the right. -->
+ <div dojoType="dijit.layout.BorderContainer"
+ gutters="true"
+ design="sidebar"
+ class="splitView">
+ <div dojoType="dijit.layout.ContentPane" region="left" style="width: 50%; overflow: auto;">
+ <font size="3"><b>Demo Searcher (Searches on Attribute 'name'):</b></font><br/><br/>
+ <b>Usage:</b><br/>
+ Enter the name you want to search the store for. Wildcards * (multiple character), and ? (single character), are allowed.
+ <br/>
+ <br/>
+ <table style="width: 90%;">
+ <tr>
+ <td align="left">
+ <div dojoType="dijit.form.Button" jsId="searchButton">Search Datastore</div>
+ </td>
+ <td align="right">
+ <div dojoType="dijit.form.TextBox" jsId="inputField" value="*" intermediateChanges="true"></div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div dojoType="dijit.layout.ContentPane" region="right" style="width: 50%; overflow: auto;">
+ <div class="dataTable" dojoType="dojox.wire.demos.TableContainer" jsId="dataTable" headers="Name,Location Type"></div>
+ </div>
+ </div>
+
+ <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
+
+ <!-- The store that is queried in this demo -->
+ <div dojoType="dojo.data.ItemFileReadStore"
+ jsId="DataStore1"
+ url="countries.json">
+ </div>
+
+ <!--
+ When the search button is clicked, clear existing rows from table,
+ Then invoke the fetch to repopulate the table.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="searchButton"
+ triggerEvent="onClick">
+ <div dojoType="dojox.wire.ml.Invocation" object="dataTable" method="clearTable"></div>
+ <div dojoType="dojox.wire.ml.Invocation" object="DataStore1" method="fetch" parameters="dataHolder.request"></div>
+ </div>
+
+ <!--
+ Link existing of the text box to transfering the search string to the query param.
+ We are wiring the value of TextBox value of the widget to the name property of our request
+ object. The copy of values to the search should occur on each keyup event (each keypress)
+ -->
+ <div dojoType="dojox.wire.ml.Transfer"
+ trigger="inputField" triggerEvent="onChange"
+ source="inputField.textbox.value"
+ target="dataHolder.request.query.name">
+ </div>
+
+ <!--
+ On the call of the onItem function of 'dataHolder', trigger a binding/mapping of the
+ item's attribute 'name' and 'type' attributes to specific columns in an array. Note here that since
+ sourceStore is set, it treats the arguments as items from that store and accesses the attributes
+ appropriately. In this case 'name' becomes array entry 0, type, array entry 1, and so on.
+
+ Then take the result of the data mapping and pass it into the invoke of the addRow function on the
+ TableContainer widget.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="dataHolder.request" triggerEvent="onItem">
+ <div dojoType="dojox.wire.ml.Transfer"
+ source="arguments[0]" sourceStore="DataStore1"
+ target="dataHolder.result">
+ <div dojoType="dojox.wire.ml.ColumnWire" attribute="name"></div>
+ <div dojoType="dojox.wire.ml.ColumnWire" attribute="type"></div>
+ </div>
+ <div dojoType="dojox.wire.ml.Invocation"
+ object="dataTable" method="addRow" parameters='dataHolder.result'>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/js/dojo/dojox/wire/demos/markup/demo_BasicChildWire.html b/js/dojo/dojox/wire/demos/markup/demo_BasicChildWire.html
new file mode 100644
index 0000000..f5973e7
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/demo_BasicChildWire.html
@@ -0,0 +1,78 @@
+<!--
+ This file demonstrates how the dojox.wire code can be used to do declarative
+ wiring of properties/attributes of some object to the properties/attributes of
+ another object. It specifically uses the Child (Composite) wire type to perform
+ the mapping.
+
+ Note that this demo expects dojo, digit, and dojox to all be peers in the same directory
+ in order for it to execute.
+-->
+<html>
+ <head>
+ <title>Sample Composite (Child) Wire usage.</title>
+ <style type="text/css">
+ @import "../../../../dijit/themes/tundra/tundra.css";
+ @import "../../../../dojo/resources/dojo.css";
+ @import "../../../../dijit/tests/css/dijitTests.css";
+ </style>
+
+ <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dijit.form.Button");
+ dojo.require("dojo.data.ItemFileReadStore");
+ dojo.require("dojox.wire.ml.Invocation");
+ dojo.require("dojox.wire.ml.DataStore");
+ dojo.require("dojox.wire.ml.Transfer");
+ dojo.require("dojox.wire");
+ dojo.require("dojox.wire.demos.WidgetRepeater");
+
+ dataHolder = {
+ request: {onItem: function(item){}},
+ result: null
+ };
+ </script>
+ </head>
+ <body class="tundra">
+ <!--
+ On load of the page, invoke the fetch method of the object 'DataStore1',
+ get its parameters from the JS object 'sample.request
+ -->
+ <div dojoType="dojox.wire.ml.Invocation"
+ triggerEvent="onLoad"
+ object="DataStore1" method="fetch" parameters="dataHolder.request">
+ </div>
+
+ <!--
+ The store that is queried in this demo
+ -->
+ <div dojoType="dojo.data.ItemFileReadStore"
+ jsId="DataStore1"
+ url="countries.json">
+ </div>
+
+ <!--
+ Simple container widget for creating a 'list' of some set of widgets
+ As defined by the widget type it contains.
+ -->
+ <div dojoType="dojox.wire.demos.WidgetRepeater"
+ widget="dijit.form.Button" jsId="r1">
+ </div>
+
+ <!--
+ On the call of the onItem function of 'sample', trigger a binding/mapping of the
+ item's attribute 'name' to the target object property: dataHolder.result.caption
+ Then invoke the WidgetRepeater (r1)'s createNew method, using the parameters from
+ dataHolder.result.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="dataHolder.request" triggerEvent="onItem">
+ <div dojoType="dojox.wire.ml.Transfer"
+ source="arguments[0]" sourceStore="DataStore1"
+ target="dataHolder.result">
+ <div dojoType="dojox.wire.ml.ChildWire" name="label" attribute="name"></div>
+ </div>
+ <div dojoType="dojox.wire.ml.Invocation" object="r1" method="createNew" parameters='dataHolder.result'></div>
+ </div>
+ </body>
+</html>
diff --git a/js/dojo/dojox/wire/demos/markup/demo_BasicColumnWiring.html b/js/dojo/dojox/wire/demos/markup/demo_BasicColumnWiring.html
new file mode 100644
index 0000000..48c327e
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/demo_BasicColumnWiring.html
@@ -0,0 +1,90 @@
+<!--
+ This file demonstrates how the dojox.wire code can be used to do declarative
+ wiring of events on one item to trigger event on other items. It also shows
+ how you can use the Transfer object to morph data values from one format to
+ another. In this specific case, it maps the values from a dojo.data Datastore
+ item into values stored in a JavaScript Array, which is the format required for
+ the addRow method of the demonstration TableContainer.
+
+ Note that this demo expects dojo, digit, and dojox to all be peers in the same directory
+ in order for it to execute.
+-->
+<html>
+<head>
+ <title>Sample Declarative Data Binding using ColumnWire</title>
+ <style type="text/css">
+ @import "../../../../dijit/themes/tundra/tundra.css";
+ @import "../../../../dojo/resources/dojo.css";
+ @import "../../../../dijit/tests/css/dijitTests.css";
+ @import "../TableContainer.css";
+ </style>
+
+ <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dojox.wire.ml.Invocation");
+ dojo.require("dojox.wire.ml.DataStore");
+ dojo.require("dojox.wire.ml.Transfer");
+
+ dojo.require("dijit._Widget");
+ dojo.require("dijit._Templated");
+ dojo.require("dojo.data.ItemFileReadStore");
+ dojo.require("dojox.wire");
+ dojo.require("dojox.wire.demos.TableContainer");
+
+ //Toplevel JS Object to contain a few basics for us, such as the request to pass to the store and a stub onItem function
+ // to trap on for triggering other events.
+ dataHolder = {
+ //Simple object definition to get all items and sort it by the attribute 'type'.
+ request: {onItem: function(item){}, sort: [{attribute: "type"}]},
+ //Spot to store off data values as they're generated by the declarative binding.
+ result: null
+ };
+ </script>
+</head>
+
+<body class="tundra">
+ <!--
+ The store that is queried in this demo
+ -->
+ <div dojoType="dojo.data.ItemFileReadStore"
+ jsId="DataStore1"
+ url="countries.json">
+ </div>
+
+ <!--
+ On load of the page, invoke the fetch method of the object 'DataStore1',
+ get its parameters from the JS object 'sample.request
+ -->
+ <div dojoType="dojox.wire.ml.Invocation"
+ triggerEvent="onLoad"
+ object="DataStore1" method="fetch" parameters="dataHolder.request"></div>
+
+ <!--
+ Simple container widget for creating a 'table from rows defined by an array
+ -->
+ <div dojoType="dojox.wire.demos.TableContainer" jsId="r1" headers="Name,Location Type"></div>
+
+ <!--
+ On the call of the onItem function of 'dataHolder', trigger a binding/mapping of the
+ item's attribute 'name' and 'type' attributes to specific columns in an array. Note here that since
+ sourceStore is set, it treats the arguments as items from that store and accesses the attributes
+ appropriately. In this case 'name' becomes array entry 0, type, array entry 1, and so on.
+
+ Then take the result of the data mapping and pass it into the invoke of the addRow function on the
+ TableContainer widget.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="dataHolder.request" triggerEvent="onItem">
+ <div dojoType="dojox.wire.ml.Transfer"
+ source="arguments[0]" sourceStore="DataStore1"
+ target="dataHolder.result">
+ <div dojoType="dojox.wire.ml.ColumnWire" attribute="name"></div>
+ <div dojoType="dojox.wire.ml.ColumnWire" attribute="type"></div>
+ </div>
+ <div dojoType="dojox.wire.ml.Invocation"
+ object="r1" method="addRow" parameters='dataHolder.result'>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/js/dojo/dojox/wire/demos/markup/demo_ConditionalActions.html b/js/dojo/dojox/wire/demos/markup/demo_ConditionalActions.html
new file mode 100644
index 0000000..1a6dc91
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/demo_ConditionalActions.html
@@ -0,0 +1,221 @@
+<!--
+ This file demonstrates how the dojox.wire code can be used to do declarative
+ wiring of events. Specifically, it shows how you can wire actions to set values
+ across to other widgets, but only if certain conditions are met.
+-->
+<html>
+<head>
+ <title>Conditional Actions Demo</title>
+ <style type="text/css">
+
+ @import "../../../../dijit/themes/tundra/tundra.css";
+ @import "../../../../dojo/resources/dojo.css";
+ @import "../../../../dijit/tests/css/dijitTests.css";
+ @import "../TableContainer.css";
+
+ .splitView {
+ width: 90%;
+ height: 90%;
+ border: 1px solid #bfbfbf;
+ border-collapse: separate;
+ }
+
+ b {
+ float: left;
+ }
+
+ .rJustified {
+ float: right;
+ }
+
+ </style>
+
+ <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dojo.data.ItemFileReadStore");
+ dojo.require("dojox.wire");
+ dojo.require("dojox.wire.ml.Invocation");
+ dojo.require("dojox.wire.ml.DataStore");
+ dojo.require("dojox.wire.ml.Transfer");
+ dojo.require("dojox.wire.ml.Data");
+ dojo.require("dijit.form.TextBox");
+ dojo.require("dijit.form.CheckBox");
+ dojo.require("dijit.form.ComboBox");
+ </script>
+</head>
+
+<body class="tundra">
+
+ <!-- Layout -->
+ <font size="3"><b>Demo of Conditional Actions:</b></font><br/><br/>
+ This demo shows how you can use actions to read and set widget values, as well as have actions only occur if
+ if certain conditions are met, such as cloning values as they are typed from the billing address over to the
+ shipping address if the 'Use Same Address' checkbox is checked true.
+ <br/>
+ <br/>
+ <div dojoType="dojo.data.ItemFileReadStore" url="states.json" jsId="statesStore"></div>
+ <table width="100%">
+ <tr>
+ <td colspan="2" align="center">
+ Use Same Address: <div dojoType="dijit.form.CheckBox" id="useSameAddress" checked="true"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Billing Address</b>
+ </td>
+ <td>
+ <b>Shipping Address</b>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <b>Name:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingName" name="billingname" value="" size="50" intermediateChanges="true"></div>
+ </td>
+ <td>
+ <b>Name:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingName" name="shippingname" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Address 1:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingAddress1" name="billingaddress1" value="" size="50" intermediateChanges="true"></div>
+ </td>
+ <td>
+ <b>Address 1:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingAddress1" name="shippingaddress1" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Address 2:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingAddress2" name="billingaddress2" value="" size="50" intermediateChanges="true"></div>
+ </td>
+ <td>
+ <b>Address 2:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingAddress2" name="shippingaddress2" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>City:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingCity" name="billingcity" value="" size="50" intermediateChanges="true"></div>
+ </td>
+ <td>
+ <b>City:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingCity" name="shippingcity" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>State:</b> <div class="rJustified" dojoType="dijit.form.ComboBox" searchAttr="name" id="BillingState" name="billingstate" value="" store="statesStore" size="46"></div>
+ </td>
+ <td>
+ <b>State:</b> <div class="rJustified" dojoType="dijit.form.ComboBox" searchAttr="name" id="ShippingState" name="shippingstate" value="" store="statesStore" disabled="true" size="46"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Zip code:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="BillingZip" name="billingzip" value="" size="50" intermediateChanges="true"></div>
+ </td>
+ <td>
+ <b>Zip code:</b> <div class="rJustified" dojoType="dijit.form.TextBox" id="ShippingZip" name="shippingzip" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ </table>
+
+
+ <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
+
+ <!--
+ This is a simple data map so that the attributes we support modifying on ComboBox, TextField, etc, are lookupable.
+ since steAttribute(attr, value), replaced the single attribute setDisabled
+ -->
+ <div dojoType="dojox.wire.ml.Data"
+ id="attributesMap">
+ <div dojoType="dojox.wire.ml.DataProperty"
+ name="disabled"
+ value="disabled"></div>
+ </div>
+
+
+ <!--
+ Enable/disable the Right hand side of the shipping address view based on the checkbox events.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="useSameAddress"
+ triggerEvent="onChange">
+ <!--
+ Trigger a setting of the Shipping fields' input state based on the state of the checkbox.
+ -->
+ <div dojoType="dojox.wire.ml.Invocation" object="ShippingName" method="set" parameters="attributesMap.disabled, arguments[0]"></div>
+ <div dojoType="dojox.wire.ml.Invocation" object="ShippingAddress1" method="set" parameters="attributesMap.disabled, arguments[0]"></div>
+ <div dojoType="dojox.wire.ml.Invocation" object="ShippingAddress2" method="set" parameters="attributesMap.disabled, arguments[0]"></div>
+ <div dojoType="dojox.wire.ml.Invocation" object="ShippingCity" method="set" parameters="attributesMap.disabled, arguments[0]"></div>
+ <div dojoType="dojox.wire.ml.Invocation" object="ShippingState" method="set" parameters="attributesMap.disabled, arguments[0]"></div>
+ <div dojoType="dojox.wire.ml.Invocation" object="ShippingZip" method="set" parameters="attributesMap.disabled, arguments[0]"></div>
+ </div>
+
+ <!--
+ Clone the values of form fields while typing based on the setting of the checkbox.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="BillingName"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingName.value" target="ShippingName.value"></div>
+ </div>
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="BillingAddress1"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingAddress1.value" target="ShippingAddress1.value"></div>
+ </div>
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="BillingAddress2"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingAddress2.value" target="ShippingAddress2.value"></div>
+ </div>
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="BillingCity"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingCity.value" target="ShippingCity.value"></div>
+ </div>
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="BillingState"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingState.value" target="ShippingState.value"></div>
+ </div>
+
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="BillingZip"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.ActionFilter" required="useSameAddress.checked" requiredValue="true" type="boolean"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingZip.value" target="ShippingZip.value"></div>
+ </div>
+
+
+ <!--
+ Clone the values of form fields from billing over to shipping over if the
+ useSameAddress checkbox is set back to true.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="useSameAddress"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.ActionFilter" required="arguments[0]" requiredValue="true" type="boolean"></div>
+
+ <!--
+ Note that this uses the basic 'property' form of copying the property over and setting it. The Wire
+ code supports both getX and setX functions of setting a property as well as direct access. It first looks
+ for the getX/setX functions and if present, uses them. If missing, it will just do direct access. Because
+ of the standard getValue/setValue API of dijit form widgets, transfers work well and are compact.
+ -->
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingName.value" target="ShippingName.value"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingAddress1.value" target="ShippingAddress1.value"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingAddress2.value" target="ShippingAddress2.value"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingCity.value" target="ShippingCity.value"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingState.value" target="ShippingState.value"></div>
+ <div dojoType="dojox.wire.ml.Transfer" source="BillingZip.value" target="ShippingZip.value"></div>
+ </div>
+
+</body>
+</html>
diff --git a/js/dojo/dojox/wire/demos/markup/demo_FlickrStoreWire.html b/js/dojo/dojox/wire/demos/markup/demo_FlickrStoreWire.html
new file mode 100644
index 0000000..4d0d9ec
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/demo_FlickrStoreWire.html
@@ -0,0 +1,227 @@
+<!--
+ This file is a demo of the FlickrStore, a simple wrapper to the public feed service
+ of Flickr. This just does very basic queries against Flickr and loads the results
+ into a list viewing widget.
+-->
+<html>
+<head>
+ <title>Demo of FlickrStore</title>
+ <style type="text/css">
+
+ @import "../../../../dijit/themes/tundra/tundra.css";
+ @import "../../../../dojo/resources/dojo.css";
+ @import "../../../../dijit/tests/css/dijitTests.css";
+ @import "./flickrDemo.css";
+ </style>
+
+ <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dijit.form.TextBox");
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.ComboBox");
+ dojo.require("dijit.form.NumberSpinner");
+ dojo.require("dojox.data.FlickrStore");
+ dojo.require("dojox.wire.ml.Invocation");
+ dojo.require("dojox.wire.ml.Transfer");
+ dojo.require("dojox.wire.ml.Data");
+ dojo.require("dojox.wire");
+ dojo.require("dojox.data.demos.widgets.FlickrViewList");
+
+ //Toplevel JS Object to contain a few basics for us, such as the request to pass to the store and a stub onItem and onComplete function
+ // to trap on for triggering other events.
+ var dataHolder = {
+ //Simple stub datastore request
+ request: {query: {}}
+ };
+
+ //Function to convert the input from a widget into a comma separated list.
+ //that is the format of the store parameter.
+ var tagsInputConverter = function(tags){
+ if(tags && tags !== ""){
+ var tagsArray = tags.split(" ");
+ tags = "";
+ for(var i = 0; i < tagsArray.length; i++){
+ tags = tags + tagsArray[i];
+ if(i < (tagsArray.length - 1)){
+ tags += ","
+ }
+ }
+ }
+ return tags
+ }
+ </script>
+</head>
+
+<body class="tundra">
+ <h1>
+ DEMO: FlickrStore Search
+ </h1>
+ <hr>
+ <h3>
+ Description:
+ </h3>
+ <p>
+ This simple demo shows how services, such as Flickr, can be wrapped by the datastore API. In this demo, you can search public
+ Flickr images through a simple FlickrStore by specifying a series of tags (separated by spaces) to search on. The results
+ will be displayed below the search box. This demo is the same as the example demo provided in dojox/data/demos/demo_FlickrStore.html,
+ except that all the interactions are implemented via Wire instead of a script that runs at dojo.addOnLoad().
+ </p>
+ <p>
+ For fun, search on the 3dny tag!
+ </p>
+
+ <blockquote>
+
+ <!--
+ Layout.
+ -->
+ <table>
+ <tbody>
+ <tr>
+ <td>
+ <b>Status:</b>
+ </td>
+ <td>
+ <div dojoType="dijit.form.TextBox" size="50" id="status" jsId="statusWidget" disabled="true"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>ID:</b>
+ </td>
+ <td>
+ <div dojoType="dijit.form.TextBox" size="50" id="userid" jsId="idWidget"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Tags:</b>
+ </td>
+ <td>
+ <div dojoType="dijit.form.TextBox" size="50" id="tags" jsId="tagsWidget" value="3dny"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Tagmode:</b>
+ </td>
+ <td>
+ <select id="tagmode"
+ jsId="tagmodeWidget"
+ dojoType="dijit.form.ComboBox"
+ autocomplete="false"
+ value="any"
+ >
+ <option>any</option>
+ <option>all</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Number of Pictures:</b>
+ </td>
+ <td>
+ <div
+ id="count"
+ jsId="countWidget"
+ dojoType="dijit.form.NumberSpinner"
+ value="20"
+ constraints="{min:1,max:20,places:0}"
+ ></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ </td>
+ <td>
+ <div dojoType="dijit.form.Button" label="Search" id="searchButton" jsId="searchButtonWidget"></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </blockquote>
+ <!--
+ The store instance used by this demo.
+ -->
+ <div dojoType="dojox.data.FlickrStore" jsId="flickrStore" label="title"></div>
+ <div dojoType="dojox.data.demos.widgets.FlickrViewList" store="flickrStore" id="flickrViews" jsId="flickrViewsWidget"></div>
+
+ <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
+
+ <!--
+ This is an example of using the declarative data value definition.
+ These are effectively declarative variables to act as placeholders
+ for data values.
+ -->
+ <div dojoType="dojox.wire.ml.Data"
+ id="messageData"
+ jsId="messageData">
+ <div dojoType="dojox.wire.ml.DataProperty"
+ name="processingStart"
+ value="PROCESSING REQUEST">
+ </div>
+ <div dojoType="dojox.wire.ml.DataProperty"
+ name="processingDone"
+ value="PROCESSING COMPLETE">
+ </div>
+ </div>
+
+
+ <!--
+ When the search button is clicked, do the following in order:
+ 1.) Map the widget values over to the request properties.
+ 2.) Set the status to processing
+ 3.) Invoke the fetch on the FLickrList to repopulate the table.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="searchButtonWidget"
+ triggerEvent="onClick">
+
+ <!--
+ Read in the values from the widgets and bind them to the appropriate data locations
+ The Transfer tag looks for a getter property before using direct access, so it calls
+ getValue() to get the data from the widget, which works well for the dijit.form.* widgets.
+ -->
+ <div dojoType="dojox.wire.ml.Transfer"
+ source="idWidget.value"
+ target="dataHolder.request.query.id">
+ </div>
+
+ <!--
+ For the tags, we need to get the value and then perform a conversion on the result
+ This is done by doing a transfer through a converter.
+ -->
+ <div dojoType="dojox.wire.ml.Transfer"
+ source="tagsWidget.value"
+ target="dataHolder.request.query.tags"
+ converter="tagsInputConverter">
+ </div>
+
+ <div dojoType="dojox.wire.ml.Transfer"
+ source="tagmodeWidget.value"
+ target="dataHolder.request.query.tagmode">
+ </div>
+
+ <div dojoType="dojox.wire.ml.Transfer"
+ source="countWidget.value"
+ target="dataHolder.request.count">
+ </div>
+
+ <!-- Now invoke the actions in order. -->
+ <div dojoType="dojox.wire.ml.Transfer" target="statusWidget.value" source="messageData.processingStart"></div>
+ <div dojoType="dojox.wire.ml.Invocation" object="flickrViewsWidget" method="fetch" parameters="dataHolder.request"></div>
+ </div>
+
+ <!--
+ When the fetch processing finishes (onComplete is called), then set status to complete.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ trigger="flickrViewsWidget"
+ triggerEvent="onComplete">
+ <div dojoType="dojox.wire.ml.Transfer" target="statusWidget.value" source="messageData.processingDone"></div>
+ </div>
+
+</body>
+</html>
diff --git a/js/dojo/dojox/wire/demos/markup/demo_TopicWiring.html b/js/dojo/dojox/wire/demos/markup/demo_TopicWiring.html
new file mode 100644
index 0000000..b56fa6b
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/demo_TopicWiring.html
@@ -0,0 +1,84 @@
+<!--
+ This file demonstrates how the dojox.wire code can be used to do declarative
+ wiring of events. Specifically, it shows how you can publish and subscribe
+ to topics. In this case the setting of a value on one textbox triggers a
+ publish of that value to a topic. Another invoke is wired to fire when
+ values are published to that topic which is then displayed in another
+ textbox.
+-->
+<html>
+<head>
+ <title>Sample Topic Wiring</title>
+ <style type="text/css">
+
+ @import "../../../../dijit/themes/tundra/tundra.css";
+ @import "../../../../dojo/resources/dojo.css";
+ @import "../../../../dijit/tests/css/dijitTests.css";
+ @import "../TableContainer.css";
+
+ .splitView {
+ width: 90%;
+ height: 90%;
+ border: 1px solid #bfbfbf;
+ border-collapse: separate;
+ }
+ </style>
+
+ <script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dojox.wire");
+ dojo.require("dojox.wire.ml.Invocation");
+ dojo.require("dojox.wire.ml.DataStore");
+ dojo.require("dojox.wire.ml.Transfer");
+ dojo.require("dojox.wire.ml.Data");
+
+ dojo.require("dijit.form.TextBox");
+ </script>
+</head>
+
+<body class="tundra">
+
+ <!-- Layout -->
+ <font size="3"><b>Demo of Topic Wiring</b></font><br/><br/>
+ This demo shows how you can wire events to publish to a topic as well as receive topic events
+ <br/>
+ <br/>
+ <table>
+ <tr>
+ <td>
+ <div dojoType="dijit.form.TextBox" jsId="inputField" value="" size="50" intermediateChanges="true"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div dojoType="dijit.form.TextBox" jsId="targetField1" value="" disabled="true" size="50"></div>
+ </td>
+ </tr>
+ </table>
+
+
+ <!-------------------------------- Using dojox.wire, declaratively wire up the widgets. --------------------------->
+
+ <!--
+ Whenever a key is entered into the textbox, publish the value of it to a topic.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ id="action1"
+ trigger="inputField"
+ triggerEvent="onChange">
+ <div dojoType="dojox.wire.ml.Invocation" topic="sampleTopic" parameters="inputField.value"></div>
+ </div>
+
+ <!--
+ Whenever a value is published to a topic, set it as the value of the textbox by using Transfer to transfer the value from the
+ topic publish to the target property. The underlying wire code will invoke the proper setter for the target, in this case
+ it will invoke the dijit 'attr' function.
+ -->
+ <div dojoType="dojox.wire.ml.Action"
+ id="action2"
+ triggerTopic="sampleTopic">
+ <div dojoType="dojox.wire.ml.Transfer" target="targetField1.value" source="arguments[0]"></div>
+ </div>
+</body>
+</html>
diff --git a/js/dojo/dojox/wire/demos/markup/flickrDemo.css b/js/dojo/dojox/wire/demos/markup/flickrDemo.css
new file mode 100644
index 0000000..7e75a5d
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/flickrDemo.css
@@ -0,0 +1,35 @@
+.flickrView {
+ padding: 3 3 3 3;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #000000;
+ border-collapse: separate;
+ width: 100%;
+}
+
+.flickrView th {
+ text-align: left;
+}
+
+.flickrView tr {
+ padding: 3 3 3 3;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #000000;
+}
+
+.flickrView tr td {
+ padding: 3 3 3 3;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #000000;
+}
+
+.flickrView {
+ background-color: #EFEFEF;
+}
+
+.flickrTitle {
+ background-color: #CCCCCC;
+}
+
diff --git a/js/dojo/dojox/wire/demos/markup/states.json b/js/dojo/dojox/wire/demos/markup/states.json
new file mode 100644
index 0000000..bdaa609
--- /dev/null
+++ b/js/dojo/dojox/wire/demos/markup/states.json
@@ -0,0 +1,56 @@
+{"identifier":"abbreviation",
+"label": "label",
+"items": [
+ {"name":"Alabama", "label":"Alabama","abbreviation":"AL"},
+ {"name":"Alaska", "label":"Alaska","abbreviation":"AK"},
+ {"name":"American Samoa", "label":"American Samoa","abbreviation":"AS"},
+ {"name":"Arizona", "label":"Arizona","abbreviation":"AZ"},
+ {"name":"Arkansas", "label":"Arkansas","abbreviation":"AR"},
+ {"name":"California", "label":"California","abbreviation":"CA"},
+ {"name":"Colorado", "label":"Colorado","abbreviation":"CO"},
+ {"name":"Connecticut", "label":"Connecticut","abbreviation":"CT"},
+ {"name":"Delaware", "label":"Delaware","abbreviation":"DE"},
+ {"name":"Florida", "label":"Florida","abbreviation":"FL"},
+ {"name":"Georgia", "label":"Georgia","abbreviation":"GA"},
+ {"name":"Hawaii", "label":"Hawaii","abbreviation":"HI"},
+ {"name":"Idaho", "label":"Idaho","abbreviation":"ID"},
+ {"name":"Illinois", "label":"Illinois","abbreviation":"IL"},
+ {"name":"Indiana", "label":"Indiana","abbreviation":"IN"},
+ {"name":"Iowa", "label":"Iowa","abbreviation":"IA"},
+ {"name":"Kansas", "label":"Kansas","abbreviation":"KS"},
+ {"name":"Kentucky", "label":"Kentucky","abbreviation":"KY"},
+ {"name":"Louisiana", "label":"Louisiana","abbreviation":"LA"},
+ {"name":"Maine", "label":"Maine","abbreviation":"ME"},
+ {"name":"Marshall Islands", "label":"Marshall Islands","abbreviation":"MH"},
+ {"name":"Maryland", "label":"Maryland","abbreviation":"MD"},
+ {"name":"Massachusetts", "label":"Massachusetts","abbreviation":"MA"},
+ {"name":"Michigan", "label":"Michigan","abbreviation":"MI"},
+ {"name":"Minnesota", "label":"Minnesota","abbreviation":"MN"},
+ {"name":"Mississippi", "label":"Mississippi","abbreviation":"MS"},
+ {"name":"Missouri", "label":"Missouri","abbreviation":"MO"},
+ {"name":"Montana", "label":"Montana","abbreviation":"MT"},
+ {"name":"Nebraska", "label":"Nebraska","abbreviation":"NE"},
+ {"name":"Nevada", "label":"Nevada","abbreviation":"NV"},
+ {"name":"New Hampshire", "label":"New Hampshire","abbreviation":"NH"},
+ {"name":"New Jersey", "label":"New Jersey","abbreviation":"NJ"},
+ {"name":"New Mexico", "label":"New Mexico","abbreviation":"NM"},
+ {"name":"New York", "label":"New York","abbreviation":"NY"},
+ {"name":"North Carolina", "label":"North Carolina","abbreviation":"NC"},
+ {"name":"North Dakota", "label":"North Dakota","abbreviation":"ND"},
+ {"name":"Ohio", "label":"Ohio","abbreviation":"OH"},
+ {"name":"Oklahoma", "label":"Oklahoma","abbreviation":"OK"},
+ {"name":"Oregon", "label":"Oregon","abbreviation":"OR"},
+ {"name":"Pennsylvania", "label":"Pennsylvania","abbreviation":"PA"},
+ {"name":"Rhode Island", "label":"Rhode Island","abbreviation":"RI"},
+ {"name":"South Carolina", "label":"South Carolina","abbreviation":"SC"},
+ {"name":"South Dakota", "label":"South Dakota","abbreviation":"SD"},
+ {"name":"Tennessee", "label":"Tennessee","abbreviation":"TN"},
+ {"name":"Texas", "label":"Texas","abbreviation":"TX"},
+ {"name":"Utah", "label":"Utah","abbreviation":"UT"},
+ {"name":"Vermont", "label":"Vermont","abbreviation":"VT"},
+ {"name":"Virginia", "label":"Virginia","abbreviation":"VA"},
+ {"name":"Washington", "label":"Washington","abbreviation":"WA"},
+ {"name":"West Virginia", "label":"West Virginia","abbreviation":"WV"},
+ {"name":"Wisconsin", "label":"Wisconsin","abbreviation":"WI"},
+ {"name":"Wyoming", "label":"Wyoming","abbreviation":"WY"}
+]} \ No newline at end of file
diff --git a/js/dojo/dojox/wire/ml/Action.js b/js/dojo/dojox/wire/ml/Action.js
new file mode 100644
index 0000000..ba0c263
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/Action.js
@@ -0,0 +1,225 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/Action", ["dijit","dojo","dojox","dojo/require!dijit/_Widget,dijit/_Container,dojox/wire/Wire,dojox/wire/ml/util"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.Action");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire.Wire");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Action", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A base widget to "run" a task on an event or a topic
+ // description:
+ // This widget represents a controller task to be run when an event
+ // (a function) or a topic is issued.
+ // Sub-classes must implement _run() method to implement their tasks.
+ // 'trigger' specifies an event scope, an ID of a widget or an DOM
+ // element, or its property with the optional dotted notation.
+ // If this widget has child ActionFilter widgets, their filter()
+ // methods are called with the arguments to the event or the topic.
+ // If one of filter() methods returns false, run() won't be invoked.
+ // This widget also can serve as a composite task to run child
+ // Actions on an event or a topic specified to this widget.
+ // trigger:
+ // An event scope
+ // triggerEvent:
+ // An event (function) name
+ // triggerTopic:
+ // A topic name
+ trigger: "",
+ triggerEvent: "",
+ triggerTopic: "",
+
+ postCreate: function(){
+ // summary:
+ // Call _connect()
+ // description:
+ // See _connect().
+ this._connect();
+ },
+
+ _connect: function(){
+ // summary:
+ // Connect run() method to an event or a topic
+ // description:
+ // If 'triggerEvent' and 'trigger' are specified, connect() is
+ // used to set up run() to be called on the event.
+ // If 'triggerTopic' is specified, subscribe() is used to set up
+ // run() to be called on the topic.
+ if(this.triggerEvent){
+ if(this.trigger){
+ var scope = dojox.wire.ml._getValue(this.trigger);
+ if(scope){
+ if(!scope[this.triggerEvent]){
+ // set a dummy function for an anonymous object
+ scope[this.triggerEvent] = function(){};
+ }
+ this._triggerHandle = dojo.connect(scope, this.triggerEvent, this, "run");
+ }
+ }else{
+ var event = this.triggerEvent.toLowerCase();
+ if(event == "onload"){
+ var self = this;
+ dojo.addOnLoad(function(){
+ self._run.apply(self, arguments);
+ });
+ }
+ }
+ }else if(this.triggerTopic){
+ this._triggerHandle = dojo.subscribe(this.triggerTopic, this, "run");
+ }
+ },
+
+ _disconnect: function(){
+ // summary:
+ // Disconnect run() method from an event or a topic
+ // description:
+ // If 'triggerEvent' and 'trigger' are specified, disconnect() is
+ // used to set up run() not to be called on the event.
+ // If 'triggerTopic' is specified, unsubscribe() is used to set up
+ // run() not to be called on the topic.
+ if(this._triggerHandle){
+ if(this.triggerTopic){
+ dojo.unsubscribe(this.triggerTopic, this._triggerHandle);
+ }else{
+ dojo.disconnect(this._triggerHandle);
+ }
+ }
+ },
+
+ run: function(){
+ // summary:
+ // Run a task
+ // description:
+ // This method calls filter() method of child ActionFilter
+ // widgets.
+ // If one of them returns false, this method returns.
+ // Otherwise, _run() method is called.
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.ActionFilter){
+ if(!child.filter.apply(child, arguments)){
+ return;
+ }
+ }
+ }
+ this._run.apply(this, arguments);
+ },
+
+ _run: function(){
+ // summary:
+ // Call run() methods of child Action widgets
+ // description:
+ // If this widget has child Action widgets, their run() methods
+ // are called.
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.Action){
+ child.run.apply(child, arguments);
+ }
+ }
+ },
+
+ uninitialize: function(){
+ // summary:
+ // Over-ride of base widget unitialize function to do some connection cleanup.
+ this._disconnect();
+ return true;
+ }
+});
+
+dojo.declare("dojox.wire.ml.ActionFilter", dijit._Widget, {
+ // summary:
+ // A widget to define a filter for the parent Action to run
+ // description:
+ // This base class checks a required property specified with
+ // 'required' attribute.
+ // If 'message' is specified, the message is set to a property
+ // specified with 'error'.
+ // Subclasses may implement their own filter() method.
+ // required:
+ // A property required
+ // requiredValue:
+ // Optional. A specific value the property is required to have. If this isn't provided
+ // than any non-false/non-null value of the required propery will cause this filter
+ // to pass.
+ // type:
+ // Optional. A specific type to compare the values as (if requiredValue is set)
+ // Valid values for type are boolean, int, string. Default is string.
+ // message:
+ // An error message to emit if the filter doesn't execute due to property mismatch.
+ // error:
+ // A property to store an error due to property mismatch.
+ required: "",
+ requiredValue: "",
+ type: "",
+ message: "",
+ error: "",
+
+
+ filter: function(){
+ // summary:
+ // Check if a required property is specified. Also, if provided, check to see
+ // if the required property contains a specific value.
+ // description:
+ // If a value is undefined for a property, specified with
+ // 'required', this method returns false.
+ // If the value for a property is defined, but there isn't a requiredValue for it
+ // then any non-false value will cause the method to return true.
+ // if requiredValue is set, then filter compares that value with the value from
+ // the required property and returns true if and only if they match.
+ // The type option just allows for a way to convert the required property values
+ // into a proper form for comparison (boolean, number, etc).
+ // If 'message' is specified, it is set to a proeprty specified
+ // with 'error' or shown with alert().
+ // If 'required' starts with "arguments", a property of
+ // the method arguments are checked.
+ // returns:
+ // True if a required property is specified (and if requiredValue is specified,
+ // that they match), otherwise false
+ if(this.required === ""){
+ return true; //Boolean
+ }else{
+ var value = dojox.wire.ml._getValue(this.required, arguments);
+ if(this.requiredValue === ""){
+ //Just see if there's a value, nothing to compare it to.
+ if(value){
+ return true; //Boolean
+ }
+ }else{
+ //See if we need to type convert.
+ var reqValue = this.requiredValue;
+ if(this.type !== ""){
+ var lType = this.type.toLowerCase();
+ if(lType === "boolean"){
+ if(reqValue.toLowerCase() === "false"){
+ reqValue = false;
+ }else{
+ reqValue = true;
+ }
+ }else if(lType === "number"){
+ reqValue = parseInt(reqValue, 10);
+ }
+ }
+ if(value === reqValue){
+ return true; //boolean
+ }
+ }
+ }
+
+ if(this.message){
+ if(this.error){
+ dojox.wire.ml._setValue(this.error, this.message);
+ }else{
+ alert(this.message);
+ }
+ }
+ return false; //Boolean
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/Data.js b/js/dojo/dojox/wire/ml/Data.js
new file mode 100644
index 0000000..0c7a683
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/Data.js
@@ -0,0 +1,147 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/Data", ["dijit","dojo","dojox","dojo/require!dijit/_Widget,dijit/_Container,dojox/wire/ml/util"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.Data");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Data", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A widget for a data object
+ // description:
+ // This widget represents an object with '_properties' property.
+ // If child 'DataProperty' widgets exist, they are used to initialize
+ // propertiy values of '_properties' object.
+
+ startup: function(){
+ // summary:
+ // Call _initializeProperties()
+ // description:
+ // See _initializeProperties().
+ this._initializeProperties();
+ },
+
+ _initializeProperties: function(/*Boolean*/reset){
+ // summary:
+ // Initialize a data object
+ // description:
+ // If this widget has child DataProperty widgets, their getValue()
+ // methods are called and set the return value to a property
+ // specified by 'name' attribute of the child widgets.
+ // reset:
+ // A boolean to reset current properties
+ if(!this._properties || reset){
+ this._properties = {};
+ }
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ this.setPropertyValue(child.name, child.getValue());
+ }
+ }
+ },
+
+ getPropertyValue: function(/*String*/property){
+ // summary:
+ // Return a property value
+ // description:
+ // This method returns the value of a property, specified with
+ // 'property' argument, in '_properties' object.
+ // property:
+ // A property name
+ // returns:
+ // A property value
+ return this._properties[property]; //anything
+ },
+
+ setPropertyValue: function(/*String*/property, /*anything*/value){
+ // summary:
+ // Store a property value
+ // description:
+ // This method stores 'value' as a property, specified with
+ // 'property' argument, in '_properties' object.
+ // property:
+ // A property name
+ // value:
+ // A property value
+ this._properties[property] = value;
+ }
+});
+
+dojo.declare("dojox.wire.ml.DataProperty", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A widget to define a data property
+ // description:
+ // Attributes of this widget are used to add a property to the parent
+ // Data widget.
+ // 'type' attribute specifies one of "string", "number", "boolean",
+ // "array", "object" and "element" (DOM Element)
+ // (default to "string").
+ // If 'type' is "array" or "object", child DataProperty widgets are
+ // used to initialize the array elements or the object properties.
+ // name:
+ // A property name
+ // type:
+ // A property type name
+ // value:
+ // A property value
+ name: "",
+ type: "",
+ value: "",
+
+ _getValueAttr: function(){
+ return this.getValue();
+ },
+
+ getValue: function(){
+ // summary:
+ // Returns a property value
+ // description:
+ // If 'type' is specified, 'value' attribute is converted to
+ // the specified type and returned.
+ // Otherwise, 'value' attribute is returned as is.
+ // returns:
+ // A property value
+ var value = this.value;
+ if(this.type){
+ if(this.type == "number"){
+ value = parseInt(value);
+ }else if(this.type == "boolean"){
+ value = (value == "true");
+ }else if(this.type == "array"){
+ value = [];
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.DataProperty){
+ value.push(child.getValue());
+ }
+ }
+ }else if(this.type == "object"){
+ value = {};
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ value[child.name] = child.getValue();
+ }
+ }
+ }else if(this.type == "element"){
+ value = new dojox.wire.ml.XmlElement(value);
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ value.setPropertyValue(child.name, child.getValue());
+ }
+ }
+ }
+ }
+ return value; //anything
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/DataStore.js b/js/dojo/dojox/wire/ml/DataStore.js
new file mode 100644
index 0000000..cb40d99
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/DataStore.js
@@ -0,0 +1,117 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/DataStore", ["dijit","dojo","dojox","dojo/require!dijit/_Widget,dojox/wire/_base"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.DataStore");
+
+dojo.require("dijit._Widget");
+dojo.require("dojox.wire._base");
+
+dojo.declare("dojox.wire.ml.DataStore", dijit._Widget, {
+ // summary:
+ // A widget for a data store
+ // description:
+ // This widget represents a data store of 'storeClass' attribute.
+ // storeClass:
+ // A class name of a data store
+ storeClass: "",
+
+ postCreate: function(){
+ // summary:
+ // Call _createStore()
+ // description:
+ // See _createStore().
+ this.store = this._createStore();
+ },
+
+ _createStore: function(){
+ // summary:
+ // Create a data store
+ // desription:
+ // A data store of 'storeClass' is created with arguments
+ // specified with attributes.
+ // returns:
+ // A data store
+ if(!this.storeClass){
+ return null; //null
+ }
+ var storeClass = dojox.wire._getClass(this.storeClass);
+ if(!storeClass){
+ return null; //null
+ }
+ var args = {};
+ var attributes = this.domNode.attributes;
+ for(var i = 0; i < attributes.length; i++){
+ var a = attributes.item(i);
+ if(a.specified && !this[a.nodeName]){
+ args[a.nodeName] = a.nodeValue;
+ }
+ }
+ return new storeClass(args); //Object
+ },
+
+ getFeatures: function(){
+ // summary:
+ // Call getFeatures() method of a data store
+ // description:
+ // See dojo.data.api.Read.getFeatures().
+ // returns:
+ // A features object
+ return this.store.getFeatures(); //Object
+ },
+
+ fetch: function(/*Object*/request){
+ // summary:
+ // Call fetch() method of a data store
+ // description:
+ // See dojo.data.api.Read.fetch().
+ // request:
+ // A request object
+ // returns:
+ // A request object
+ return this.store.fetch(request); //Object
+ },
+
+ save: function(/*Object*/args){
+ // summary:
+ // Call save() method of a data store
+ // description:
+ // See dojo.data.api.Write.save().
+ // args:
+ // A save arguments object
+ this.store.save(args);
+ },
+
+ newItem: function(/*Object*/args){
+ // summary:
+ // Call newItem() method of a data store
+ // description:
+ // See dojo.data.api.Write.newItem().
+ // args:
+ // A new item arguments object
+ // returns:
+ // A new item
+ return this.store.newItem(args); //Object
+ },
+
+ deleteItem: function(/*Object*/item){
+ // summary:
+ // Call deleteItem() method of a data store
+ // description:
+ // See dojo.data.api.Write.deleteItem().
+ // returns:
+ // A boolean
+ return this.store.deleteItem(item); //Boolean
+ },
+
+ revert: function(){
+ // summary:
+ // Call revert() method of a data store
+ // description:
+ // See dojo.data.api.Write.revert().
+ // returns:
+ // A boolean
+ return this.store.revert(); //Boolean
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/Invocation.js b/js/dojo/dojox/wire/ml/Invocation.js
new file mode 100644
index 0000000..6425b83
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/Invocation.js
@@ -0,0 +1,172 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/Invocation", ["dijit","dojo","dojox","dojo/require!dojox/wire/ml/Action"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.Invocation");
+
+dojo.require("dojox.wire.ml.Action");
+
+dojo.declare("dojox.wire.ml.Invocation", dojox.wire.ml.Action, {
+ // summary:
+ // A widget to invoke a method or publish a topic
+ // description:
+ // This widget represents a controller task to invoke a method or
+ // publish a topic when an event (a function) or a topic is issued.
+ // object:
+ // A scope of a method to invoke
+ // method:
+ // A name of a method to invoke
+ // topic:
+ // A name of a topic to publish
+ // parameters:
+ // Arguments for the method or the topic
+ // result:
+ // A property to store a return value of the method call
+ // error:
+ // A property to store an error on the method call
+ object: "",
+ method: "",
+ topic: "",
+ parameters: "",
+ result: "",
+ error: "",
+
+ _run: function(){
+ // summary:
+ // Invoke a method or publish a topic
+ // description:
+ // If 'topic' is specified, the topic is published with arguments
+ // specified to 'parameters'.
+ // If 'method' and 'object' are specified, the method is invoked
+ // with arguments specified to 'parameters' and set the return
+ // value to a property specified to 'result'.
+ // 'object', 'parameters' and 'result' can specify properties of
+ // a widget or an DOM element with the dotted notation.
+ // If 'parameters' are omitted, the arguments to this method are
+ // passed as is.
+ if(this.topic){
+ var args = this._getParameters(arguments);
+ try{
+ dojo.publish(this.topic, args);
+ this.onComplete();
+ }catch(e){
+ this.onError(e);
+ }
+ }else if(this.method){
+ var scope = (this.object ? dojox.wire.ml._getValue(this.object) : dojo.global);
+ if(!scope){
+ return; //undefined
+ }
+ var args = this._getParameters(arguments);
+ var func = scope[this.method];
+ if(!func){
+ func = scope.callMethod;
+ if(!func){
+ return; //undefined
+ }
+ args = [this.method, args];
+ }
+ try{
+ var connected = false;
+ if(scope.getFeatures){
+ var features = scope.getFeatures();
+ if((this.method == "fetch" && features["dojo.data.api.Read"]) ||
+ (this.method == "save" && features["dojo.data.api.Write"])){
+ var arg = args[0];
+ if(!arg.onComplete){
+ arg.onComplete = function(){};
+ }
+ //dojo.connect(arg, "onComplete", this, "onComplete");
+ this.connect(arg, "onComplete", "onComplete");
+ if(!arg.onError){
+ arg.onError = function(){};
+ }
+ //dojo.connect(arg, "onError", this, "onError");
+ this.connect(arg, "onError", "onError");
+ connected = true;
+ }
+ }
+ var r = func.apply(scope, args);
+ if(!connected){
+ if(r && (r instanceof dojo.Deferred)){
+ var self = this;
+ r.addCallbacks(
+ function(result){self.onComplete(result);},
+ function(error){self.onError(error);}
+ );
+ }else{
+ this.onComplete(r);
+ }
+ }
+ }catch(e){
+ this.onError(e);
+ }
+ }
+ },
+
+ onComplete: function(/*anything*/result){
+ // summary:
+ // A function called when the method or the topic publish
+ // completed
+ // description:
+ // If 'result' attribute is specified, the result object also set
+ // to the specified property.
+ // result:
+ // The return value of a method or undefined for a topic
+ if(this.result){
+ dojox.wire.ml._setValue(this.result, result);
+ }
+ if(this.error){ // clear error
+ dojox.wire.ml._setValue(this.error, "");
+ }
+ },
+
+ onError: function(/*anything*/error){
+ // summary:
+ // A function called on an error occurs
+ // description:
+ // If 'error' attribute is specified, the error object also set to
+ // the specified property.
+ // error:
+ // The exception or error occurred
+ if(this.error){
+ if(error && error.message){
+ error = error.message;
+ }
+ dojox.wire.ml._setValue(this.error, error);
+ }
+ },
+
+ _getParameters: function(/*Array*/args){
+ // summary:
+ // Returns arguments to a method or topic to invoke
+ // description:
+ // This method retunrs an array of arguments specified by
+ // 'parameters' attribute, a comma-separated list of IDs and
+ // their properties in a dotted notation.
+ // If 'parameters' are omitted, the original arguments are
+ // used.
+ // args:
+ // Arguments to a trigger event or topic
+ if(!this.parameters){
+ // use arguments as is
+ return args; //Array
+ }
+ var parameters = [];
+ var list = this.parameters.split(",");
+ if(list.length == 1){
+ var parameter = dojox.wire.ml._getValue(dojo.trim(list[0]), args);
+ if(dojo.isArray(parameter)){
+ parameters = parameter;
+ }else{
+ parameters.push(parameter);
+ }
+ }else{
+ for(var i in list){
+ parameters.push(dojox.wire.ml._getValue(dojo.trim(list[i]), args));
+ }
+ }
+ return parameters; //Array
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/JsonHandler.js b/js/dojo/dojox/wire/ml/JsonHandler.js
new file mode 100644
index 0000000..e9b2f48
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/JsonHandler.js
@@ -0,0 +1,47 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/JsonHandler", ["dijit","dojo","dojox","dojo/require!dojox/wire/ml/RestHandler,dojox/wire/_base,dojox/wire/ml/util"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.JsonHandler");
+
+dojo.require("dojox.wire.ml.RestHandler");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.util");
+
+
+dojo.declare("dojox.wire.ml.JsonHandler", dojox.wire.ml.RestHandler, {
+ // summary:
+ // A REST service handler for JSON
+ // description:
+ // This class provides JSON handling for a REST service.
+ contentType: "text/json",
+ handleAs: "json",
+ headers: {"Accept": "*/json"},
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // summary:
+ // Generate a request content
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameter' is used to generate a JSON content.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ var content = null;
+ if(method == "POST" || method == "PUT"){
+ var p = (parameters ? parameters[0] : undefined);
+ if(p){
+ if(dojo.isString(p)){
+ content = p;
+ }else{
+ content = dojo.toJson(p);
+ }
+ }
+ }
+ return content; //String
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/RestHandler.js b/js/dojo/dojox/wire/ml/RestHandler.js
new file mode 100644
index 0000000..7873f31
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/RestHandler.js
@@ -0,0 +1,148 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/RestHandler", ["dijit","dojo","dojox","dojo/require!dojox/wire/_base,dojox/wire/ml/util"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.RestHandler");
+
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.RestHandler", null, {
+ // summary:
+ // A REST service handler
+ // description:
+ // This class serves as a base REST service.
+ // Sub-classes may override _getContent() and _getResult() to handle
+ // specific content types.
+ contentType: "text/plain",
+ handleAs: "text",
+
+ bind: function(method, parameters, deferred, url){
+ // summary:
+ // Call a service method with parameters.
+ // description:
+ // A service is called with a URL generated by _getUrl() and
+ // an HTTP method specified with 'method'.
+ // For "POST" and "PUT", a content is generated by _getContent().
+ // When data is loaded, _getResult() is used to pass the result to
+ // Deferred.callback().
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // deferred:
+ // 'Deferred'
+ // url:
+ // A URL for the method
+ method = method.toUpperCase();
+ var self = this;
+ var args = {
+ url: this._getUrl(method, parameters, url),
+ contentType: this.contentType,
+ handleAs: this.handleAs,
+ headers: this.headers,
+ preventCache: this.preventCache
+ };
+ var d = null;
+ if(method == "POST"){
+ args.postData = this._getContent(method, parameters);
+ d = dojo.rawXhrPost(args);
+ }else if(method == "PUT"){
+ args.putData = this._getContent(method, parameters);
+ d = dojo.rawXhrPut(args);
+ }else if(method == "DELETE"){
+ d = dojo.xhrDelete(args);
+ }else{ // "GET"
+ d = dojo.xhrGet(args);
+ }
+ d.addCallbacks(function(result){
+ deferred.callback(self._getResult(result));
+ }, function(error){
+ deferred.errback(error);
+ });
+ },
+
+ _getUrl: function(/*String*/method, /*Array*/parameters, /*String*/url){
+ // summary:
+ // Generate a URL
+ // description:
+ // If 'method' is "GET" or "DELETE", a query string is generated
+ // from a query object specified to the first parameter in
+ // 'parameters' and appended to 'url'.
+ // If 'url' contains variable seguments ("{parameter_name}"),
+ // they are replaced with corresponding parameter values, instead.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // url:
+ // A base URL
+ // returns:
+ // A URL
+ var query;
+ if(method == "GET" || method == "DELETE"){
+ if(parameters.length > 0){
+ query = parameters[0];
+ }
+ }else{ // "POST" || "PUT"
+ if(parameters.length > 1){
+ query = parameters[1];
+ }
+ }
+ if(query){
+ var queryString = "";
+ for(var name in query){
+ var value = query[name];
+ if(value){
+ value = encodeURIComponent(value);
+ var variable = "{" + name + "}";
+ var index = url.indexOf(variable);
+ if(index >= 0){ // encode in path
+ url = url.substring(0, index) + value + url.substring(index + variable.length);
+ }else{ // encode as query string
+ if(queryString){
+ queryString += "&";
+ }
+ queryString += (name + "=" + value);
+ }
+ }
+ }
+ if(queryString){
+ url += "?" + queryString;
+ }
+ }
+ return url; //String
+ },
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // summary:
+ // Generate a request content
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameters' is returned.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ if(method == "POST" || method == "PUT"){
+ return (parameters ? parameters[0] : null); //anything
+ }else{
+ return null; //null
+ }
+ },
+
+ _getResult: function(/*anything*/data){
+ // summary:
+ // Extract a result
+ // description:
+ // A response data is returned as is.
+ // data:
+ // A response data returned by a service
+ // returns:
+ // A result object
+ return data; //anything
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/Service.js b/js/dojo/dojox/wire/ml/Service.js
new file mode 100644
index 0000000..7c2dce1
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/Service.js
@@ -0,0 +1,107 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/Service", ["dijit","dojo","dojox","dojo/require!dijit/_Widget,dojox/xml/parser,dojox/wire/_base,dojox/wire/ml/util"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.Service");
+
+dojo.require("dijit._Widget");
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Service", dijit._Widget, {
+ // summary:
+ // A widget for a service
+ // description:
+ // This widget represents a service defined by a service description
+ // specified with 'url' attribute.
+ // If 'serviceType' and 'serviceUrl' attributes are specified, 'url'
+ // attribute can be omitted.
+ // url:
+ // A URL to a service description
+ // serviceUrl:
+ // A URL to a service
+ // serviceType:
+ // A service type
+ // handlerClass:
+ // A service handler class name
+ url: "",
+ serviceUrl: "",
+ serviceType: "",
+ handlerClass: "",
+ preventCache: true,
+
+ postCreate: function(){
+ // summary:
+ // Call _createHandler()
+ // description:
+ // See _createHandler().
+ this.handler = this._createHandler();
+ },
+
+ _handlerClasses: {
+ "TEXT": "dojox.wire.ml.RestHandler",
+ "XML": "dojox.wire.ml.XmlHandler",
+ "JSON": "dojox.wire.ml.JsonHandler",
+ "JSON-RPC": "dojo.rpc.JsonService"
+ },
+
+ _createHandler: function(){
+ // summary:
+ // Create a service handler
+ // desription:
+ // A service handler class is determined by:
+ // 1. 'handlerClass' attribute
+ // 2. 'serviceType' attribute
+ // 3. 'serviceType' property in a service description
+ // returns:
+ // A service handler
+ if(this.url){
+ var self = this;
+ var d = dojo.xhrGet({
+ url: this.url,
+ handleAs: "json",
+ sync: true
+ });
+ d.addCallback(function(result){
+ self.smd = result;
+ });
+ if(this.smd && !this.serviceUrl){
+ this.serviceUrl = (this.smd.serviceUrl || this.smd.serviceURL);
+ }
+ }
+ var handlerClass = undefined;
+ if(this.handlerClass){
+ handlerClass = dojox.wire._getClass(this.handlerClass);
+ }else if(this.serviceType){
+ handlerClass = this._handlerClasses[this.serviceType];
+ if(handlerClass && dojo.isString(handlerClass)){
+ handlerClass = dojox.wire._getClass(handlerClass);
+ this._handlerClasses[this.serviceType] = handlerClass;
+ }
+ }else if(this.smd && this.smd.serviceType){
+ handlerClass = this._handlerClasses[this.smd.serviceType];
+ if(handlerClass && dojo.isString(handlerClass)){
+ handlerClass = dojox.wire._getClass(handlerClass);
+ this._handlerClasses[this.smd.serviceType] = handlerClass;
+ }
+ }
+ if(!handlerClass){
+ return null; //null
+ }
+ return new handlerClass(); //Object
+ },
+
+ callMethod: function(method, parameters){
+ // summary:
+ // Call a service method with parameters
+ // method:
+ // A method name
+ // parameters:
+ // An array parameters
+ var deferred = new dojo.Deferred();
+ this.handler.bind(method, parameters, deferred, this.serviceUrl);
+ return deferred;
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/Transfer.js b/js/dojo/dojox/wire/ml/Transfer.js
new file mode 100644
index 0000000..bbc6dc5
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/Transfer.js
@@ -0,0 +1,356 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/Transfer", ["dijit","dojo","dojox","dojo/require!dijit/_Widget,dijit/_Container,dojox/wire/_base,dojox/wire/ml/Action"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.Transfer");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.Action");
+
+dojo.declare("dojox.wire.ml.Transfer", dojox.wire.ml.Action, {
+ // summary:
+ // A widget to transfer values through source and target Wires
+ // description:
+ // This widget represents a controller task to transfer a value from
+ // a source to a target, through a source and a target Wires, when
+ // an event (a function) or a topic is issued.
+ // If this widget has child ChildWire widgets, their _addWire()
+ // methods are called to add Wire arguments to a source or a target
+ // Wire.
+ // source:
+ // A source object and/or property
+ // sourceStore:
+ // A data store for a source data item
+ // sourceAttribute:
+ // An attribute of a source data item
+ // sourcePath:
+ // A simplified XPath to a source property of an XML element
+ // type:
+ // A type of the value to be transferred
+ // converter:
+ // A class name of a converter for the value to be transferred
+ // target:
+ // A target object and/or property
+ // targetStore:
+ // A data store for a target data item
+ // targetAttribute:
+ // An attribute of a target data item
+ // targetPath:
+ // A simplified XPath to a target property of an XML element
+ source: "",
+ sourceStore: "",
+ sourceAttribute: "",
+ sourcePath: "",
+ type: "",
+ converter: "",
+ delimiter: "",
+ target: "",
+ targetStore: "",
+ targetAttribute: "",
+ targetPath: "",
+
+ _run: function(){
+ // summary:
+ // Transfer a value from a source to a target
+ // description:
+ // First, Wires for a source and a target are created from attributes.
+ // Then, a value is obtained by getValue() of the source Wire is set
+ // by setValue() of the target Wire.
+ // The arguments to this method is passed to getValue() and setValue()
+ // of Wires, so that they can be used to identify the root objects off
+ // the arguments.
+ var sourceWire = this._getWire("source");
+ var targetWire = this._getWire("target");
+ dojox.wire.transfer(sourceWire, targetWire, arguments);
+ },
+
+ _getWire: function(/*String*/which){
+ // summary:
+ // Build Wire arguments from attributes
+ // description:
+ // Arguments object for a source or a target Wire, specified by
+ // 'which' argument, are build from corresponding attributes,
+ // including '*Store' (for 'dataStore'), '*Attribute'
+ // (for 'attribute), '*Path' (for 'path'), 'type' and 'converter'.
+ // 'source' or 'target' attribute is parsed as:
+ // "object_id.property_name[.sub_property_name...]"
+ // If 'source' or 'target' starts with "arguments", 'object'
+ // argument for a Wire is set to null, so that the root object is
+ // given as an event or topic arguments.
+ // If this widget has child ChildWire widgets with a corresponding
+ // 'which' attribute, their _addWire() methods are called to add
+ // additional Wire arguments and nested Wire is created,
+ // specifying the Wire defined by this widget to 'object' argument.
+ // which:
+ // Which Wire arguments to build, "source" or "target"
+ // returns:
+ // Wire arguments object
+ var args = undefined;
+ if(which == "source"){
+ args = {
+ object: this.source,
+ dataStore: this.sourceStore,
+ attribute: this.sourceAttribute,
+ path: this.sourcePath,
+ type: this.type,
+ converter: this.converter
+ };
+ }else{ // "target"
+ args = {
+ object: this.target,
+ dataStore: this.targetStore,
+ attribute: this.targetAttribute,
+ path: this.targetPath
+ };
+ }
+ if(args.object){
+ if(args.object.length >= 9 && args.object.substring(0, 9) == "arguments"){
+ args.property = args.object.substring(9);
+ args.object = null;
+ }else{
+ var i = args.object.indexOf('.');
+ if(i < 0){
+ args.object = dojox.wire.ml._getValue(args.object);
+ }else{
+ args.property = args.object.substring(i + 1);
+ args.object = dojox.wire.ml._getValue(args.object.substring(0, i));
+ }
+ }
+ }
+ if(args.dataStore){
+ args.dataStore = dojox.wire.ml._getValue(args.dataStore);
+ }
+ var childArgs = undefined;
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.ChildWire && child.which == which){
+ if(!childArgs){
+ childArgs = {};
+ }
+ child._addWire(this, childArgs);
+ }
+ }
+ if(childArgs){ // make nested Wires
+ childArgs.object = dojox.wire.create(args);
+ childArgs.dataStore = args.dataStore;
+ args = childArgs;
+ }
+ return args; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.ChildWire", dijit._Widget, {
+ // summary:
+ // A widget to add a child wire
+ // description:
+ // Attributes of this widget are used to add a child Wire to
+ // a composite Wire of the parent Transfer widget.
+ // which:
+ // Which Wire to add a child Wire, "source" or "target", default to
+ // "source"
+ // object:
+ // A root object for the value
+ // property:
+ // A property for the value
+ // type:
+ // A type of the value
+ // converter:
+ // A class name of a converter for the value
+ // attribute:
+ // A data item attribute for the value
+ // path:
+ // A simplified XPath for the value
+ // name:
+ // A composite property name
+ which: "source",
+ object: "",
+ property: "",
+ type: "",
+ converter: "",
+ attribute: "",
+ path: "",
+ name: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a child Wire to Wire arguments
+ // description:
+ // If 'name' attribute is specified, a child Wire is added as
+ // the named property of 'children' object of 'args'.
+ // Otherwise, a child Wire is added to 'children' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(this.name){ // object
+ if(!args.children){
+ args.children = {};
+ }
+ args.children[this.name] = this._getWire(parent);
+ }else{ // array
+ if(!args.children){
+ args.children = [];
+ }
+ args.children.push(this._getWire(parent));
+ }
+ },
+
+ _getWire: function(/*Transfer*/parent){
+ // summary:
+ // Build child Wire arguments from attributes
+ // description:
+ // Arguments object for a child Wire are build from attributes,
+ // including 'object', 'property', 'type', 'converter',
+ // 'attribute' and 'path'.
+ // parent:
+ // A parent Transfer widget
+ // returns:
+ // Wire arguments object
+ return {
+ object: (this.object ? dojox.wire.ml._getValue(this.object) : undefined),
+ property: this.property,
+ type: this.type,
+ converter: this.converter,
+ attribute: this.attribute,
+ path: this.path
+ }; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.ColumnWire", dojox.wire.ml.ChildWire, {
+ // summary:
+ // A widget to add a column wire
+ // description:
+ // Attributes of this widget are used to add a column Wire to
+ // a TableAdapter of the parent Transfer widget.
+ // column:
+ // A column name
+ column: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a column Wire to Wire arguments
+ // description:
+ // If 'column' attribute is specified, a column Wire is added as
+ // the named property of 'columns' object of 'args'.
+ // Otherwise, a column Wire is added to 'columns' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(this.column){ // object
+ if(!args.columns){
+ args.columns = {};
+ }
+ args.columns[this.column] = this._getWire(parent);
+ }else{ // array
+ if(!args.columns){
+ args.columns = [];
+ }
+ args.columns.push(this._getWire(parent));
+ }
+ }
+});
+
+dojo.declare("dojox.wire.ml.NodeWire", [dojox.wire.ml.ChildWire, dijit._Container], {
+ // summary:
+ // A widget to add node wires
+ // description:
+ // Attributes of this widget are used to add node Wires to
+ // a TreeAdapter of the parent Transfer widget.
+ // titleProperty:
+ // A property for the node title
+ // titleAttribute:
+ // A data item attribute for the node title
+ // titlePath:
+ // A simplified XPath for the node title
+ titleProperty: "",
+ titleAttribute: "",
+ titlePath: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add node Wires to Wire arguments
+ // description:
+ // Node Wires are added to 'nodes' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(!args.nodes){
+ args.nodes = [];
+ }
+ args.nodes.push(this._getWires(parent));
+ },
+
+ _getWires: function(/*Transfer*/parent){
+ // summary:
+ // Build node Wires arguments from attributes
+ // description:
+ // Arguments object for 'node' Wire are build from attributes,
+ // including 'object', 'property', 'type', 'converter',
+ // 'attribute' and 'path'.
+ // Arguments object for 'title' Wire are build from another set of
+ // attributes, 'titleProperty', 'titleAttribute' and 'titlePath'.
+ // If this widget has child NodeWire widgets, their _getWires()
+ // methods are called recursively to build 'children' array of
+ // 'args'.
+ // parent:
+ // A parent Transfer widget
+ // returns:
+ // Wire arguments object
+ var args = {
+ node: this._getWire(parent),
+ title: {
+ type: "string",
+ property: this.titleProperty,
+ attribute: this.titleAttribute,
+ path: this.titlePath
+ }
+ };
+ var childArgs = [];
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.NodeWire){
+ childArgs.push(child._getWires(parent));
+ }
+ }
+ if(childArgs.length > 0){
+ args.children = childArgs;
+ }
+ return args; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.SegmentWire", dojox.wire.ml.ChildWire, {
+ // summary:
+ // A widget to add a segment wire
+ // description:
+ // Attributes of this widget are used to add a segment Wire to
+ // a TextAdapter of the parent Transfer widget.
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a segument Wire to Wire arguments
+ // description:
+ // A segment Wire is added to 'segments' array of 'args'.
+ // If 'parent' has 'delimiter' attribute, it is used for
+ // 'delimiter' property of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(!args.segments){
+ args.segments = [];
+ }
+ args.segments.push(this._getWire(parent));
+ if(parent.delimiter && !args.delimiter){
+ args.delimiter = parent.delimiter;
+ }
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/XmlHandler.js b/js/dojo/dojox/wire/ml/XmlHandler.js
new file mode 100644
index 0000000..9163216
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/XmlHandler.js
@@ -0,0 +1,68 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/XmlHandler", ["dijit","dojo","dojox","dojo/require!dojox/wire/ml/RestHandler,dojox/xml/parser,dojox/wire/_base,dojox/wire/ml/util"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.XmlHandler");
+
+dojo.require("dojox.wire.ml.RestHandler");
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.util");
+
+
+dojo.declare("dojox.wire.ml.XmlHandler", dojox.wire.ml.RestHandler, {
+ // summary:
+ // A REST service handler for XML
+ // description:
+ // This class provides XML handling for a REST service.
+ contentType: "text/xml",
+ handleAs: "xml",
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameters' is used to generate an XML content.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ var content = null;
+ if(method == "POST" || method == "PUT"){
+ var p = parameters[0];
+ if(p){
+ if(dojo.isString(p)){
+ content = p;
+ }else{
+ var element = p;
+ if(element instanceof dojox.wire.ml.XmlElement){
+ element = element.element;
+ }else if(element.nodeType === 9 /* DOCUMENT_NODE */){
+ element = element.documentElement;
+ }
+ var declaration = "<?xml version=\"1.0\"?>"; // TODO: encoding?
+ content = declaration + dojox.xml.parser.innerXML(element);
+ }
+ }
+ }
+ return content;
+ },
+
+ _getResult: function(/*Document*/data){
+ // summary:
+ // Extract a result
+ // description:
+ // A response data (XML Document) is returned wrapped with
+ // XmlElement.
+ // data:
+ // A response data returned by a service
+ // returns:
+ // A result object
+ if(data){
+ data = new dojox.wire.ml.XmlElement(data);
+ }
+ return data;
+ }
+});
+
+});
diff --git a/js/dojo/dojox/wire/ml/util.js b/js/dojo/dojox/wire/ml/util.js
new file mode 100644
index 0000000..d99b644
--- /dev/null
+++ b/js/dojo/dojox/wire/ml/util.js
@@ -0,0 +1,300 @@
+//>>built
+// wrapped by build app
+define("dojox/wire/ml/util", ["dijit","dojo","dojox","dojo/require!dojox/xml/parser,dojox/wire/Wire"], function(dijit,dojo,dojox){
+dojo.provide("dojox.wire.ml.util");
+
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire.Wire");
+
+dojox.wire.ml._getValue = function(/*String*/source, /*Array*/args){
+ // summary:
+ // Return a value
+ // description:
+ // This method obtains an object by an ID of a widget or an DOM
+ // element.
+ // If 'source' specifies a dotted notation to its property, a Wire is
+ // used to get the object property.
+ // If 'source' starts with "arguments", 'args' is used as a root
+ // object for the Wire.
+ // source:
+ // A string to specify an object and its property
+ // args:
+ // An optional arguments array
+ // returns:
+ // A value
+ if(!source){
+ return undefined; //undefined
+ }
+ var property = undefined;
+ if(args && source.length >= 9 && source.substring(0, 9) == "arguments"){
+ property = source.substring(9);
+ return new dojox.wire.Wire({property: property}).getValue(args);
+ }
+ var i = source.indexOf('.');
+ if(i >= 0){
+ property = source.substring(i + 1);
+ source = source.substring(0, i);
+ }
+ var object = (dijit.byId(source) || dojo.byId(source) || dojo.getObject(source));
+ if(!object){
+ return undefined; //undefined
+ }
+ if(!property){
+ return object; //Object
+ }else{
+ return new dojox.wire.Wire({object: object, property: property}).getValue(); //anything
+ }
+};
+
+dojox.wire.ml._setValue = function(/*String*/target, /*anything*/value){
+ // summary:
+ // Store a value
+ // description:
+ // This method stores a value by an ID of a widget or an DOM
+ // element with a dotted notation to its property, using a Wire.
+ // target:
+ // A string to specify an object and its property
+ // value:
+ // A value
+ if(!target){
+ return; //undefined
+ }
+ var i = target.indexOf('.');
+ if(i < 0){
+ return; //undefined
+ }
+ var object = this._getValue(target.substring(0, i));
+ if(!object){
+ return; //undefined
+ }
+ var property = target.substring(i + 1);
+ var wire = new dojox.wire.Wire({object: object, property: property}).setValue(value);
+};
+
+dojo.declare("dojox.wire.ml.XmlElement", null, {
+ // summary:
+ // An object wrapping an XML element
+ // description:
+ // This class represents an XML element.
+
+ constructor: function(/*Element||String*/element){
+ // summary:
+ // Initialize with an XML element or a tag name
+ // element:
+ // An XML element or a tag name
+ if(dojo.isString(element)){
+ element = this._getDocument().createElement(element);
+ }
+ this.element = element;
+ },
+ getPropertyValue: function(/*String*/property){
+ // summary:
+ // Return a property value
+ // description:
+ // If 'property' starts with '@', the attribute value is returned.
+ // If 'property' specifies "text()", the value of the first child
+ // text is returned.
+ // Otherwise, child elements of the tag name specified with
+ // 'property' are returned.
+ // property:
+ // A property name
+ // returns:
+ // A property value
+ var value = undefined;
+ if(!this.element){
+ return value; //undefined
+ }
+ if(!property){
+ return value; //undefined
+ }
+
+ if(property.charAt(0) == '@'){
+ var attribute = property.substring(1);
+ value = this.element.getAttribute(attribute);
+ }else if(property == "text()"){
+ var text = this.element.firstChild;
+ if(text){
+ value = text.nodeValue;
+ }
+ }else{ // child elements
+ var elements = [];
+ for(var i = 0; i < this.element.childNodes.length; i++){
+ var child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
+ elements.push(new dojox.wire.ml.XmlElement(child));
+ }
+ }
+ if(elements.length > 0){
+ if(elements.length === 1){
+ value = elements[0];
+ }else{
+ value = elements;
+ }
+ }
+ }
+ return value; //String||Array||XmlElement
+ },
+
+ setPropertyValue: function(/*String*/property, /*String||Array||XmlElement*/value){
+ // summary:
+ // Store a property value
+ // description:
+ // If 'property' starts with '@', 'value' is set to the attribute.
+ // If 'property' specifies "text()", 'value' is set as the first
+ // child text.
+ // If 'value' is a string, a child element of the tag name
+ // specified with 'property' is created and 'value' is set as
+ // the first child text of the child element.
+ // Otherwise, 'value' is set to as child elements.
+ // property:
+ // A property name
+ // value:
+ // A property value
+ var i;
+ var text;
+ if(!this.element){
+ return; //undefined
+ }
+ if(!property){
+ return; //undefined
+ }
+
+ if(property.charAt(0) == '@'){
+ var attribute = property.substring(1);
+ if(value){
+ this.element.setAttribute(attribute, value);
+ }else{
+ this.element.removeAttribute(attribute);
+ }
+ }else if(property == "text()"){
+ while(this.element.firstChild){
+ this.element.removeChild(this.element.firstChild);
+ }
+ if(value){
+ text = this._getDocument().createTextNode(value);
+ this.element.appendChild(text);
+ }
+ }else{ // child elements
+ var nextChild = null;
+ var child;
+ for(i = this.element.childNodes.length - 1; i >= 0; i--){
+ child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
+ if(!nextChild){
+ nextChild = child.nextSibling;
+ }
+ this.element.removeChild(child);
+ }
+ }
+ if(value){
+ if(dojo.isArray(value)){
+ for(i in value){
+ var e = value[i];
+ if(e.element){
+ this.element.insertBefore(e.element, nextChild);
+ }
+ }
+ }else if(value instanceof dojox.wire.ml.XmlElement){
+ if(value.element){
+ this.element.insertBefore(value.element, nextChild);
+ }
+ }else{ // assume string
+ child = this._getDocument().createElement(property);
+ text = this._getDocument().createTextNode(value);
+ child.appendChild(text);
+ this.element.insertBefore(child, nextChild);
+ }
+ }
+ }
+ },
+
+ toString: function(){
+ // summary:
+ // Return a value of the first text child of the element
+ // description:
+ // A value of the first text child of the element is returned.
+ // returns:
+ // A value of the first text child of the element
+ var s = "";
+ if(this.element){
+ var text = this.element.firstChild;
+ if(text){
+ s = text.nodeValue;
+ }
+ }
+ return s; //String
+ },
+
+ toObject: function(){
+ // summary:
+ // Return an object representation of the element
+ // description:
+ // An object with properties for child elements, attributes and
+ // text is returned.
+ // returns:
+ // An object representation of the element
+ if(!this.element){
+ return null; //null
+ }
+ var text = "";
+ var obj = {};
+ var elements = 0;
+ var i;
+ for(i = 0; i < this.element.childNodes.length; i++){
+ var child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */){
+ elements++;
+ var o = new dojox.wire.ml.XmlElement(child).toObject();
+ var name = child.nodeName;
+ var p = obj[name];
+ if(!p){
+ obj[name] = o;
+ }else if(dojo.isArray(p)){
+ p.push(o);
+ }else{
+ obj[name] = [p, o]; // make them array
+ }
+ }else if(child.nodeType === 3 /* TEXT_NODE */ ||
+ child.nodeType === 4 /* CDATA_SECTION_NODE */){
+ text += child.nodeValue;
+ }
+ }
+ var attributes = 0;
+ if(this.element.nodeType === 1 /* ELEMENT_NODE */){
+ attributes = this.element.attributes.length;
+ for(i = 0; i < attributes; i++){
+ var attr = this.element.attributes[i];
+ obj["@" + attr.nodeName] = attr.nodeValue;
+ }
+ }
+ if(elements === 0){
+ if(attributes === 0){
+ // text only
+ return text; //String
+ }
+ // text with attributes
+ obj["text()"] = text;
+ }
+ // else ignore text
+ return obj; //Object
+ },
+
+ _getDocument: function(){
+ // summary:
+ // Return a DOM document
+ // description:
+ // If 'element' is specified, a DOM document of the element is
+ // returned.
+ // Otherwise, a DOM document is created.
+ // returns:
+ // A DOM document
+ if(this.element){
+ return (this.element.nodeType == 9 /* DOCUMENT_NODE */ ?
+ this.element : this.element.ownerDocument); //Document
+ }else{
+ return dojox.xml.parser.parse(); //Document
+ }
+ }
+});
+
+});