dojox/wire/DataWire.js

  • Provides:

    • dojox.wire.DataWire
  • Requires:

    • dojox.wire.Wire in common
  • dojox.wire.DataWire

    • type
      Function
    • chains:
      • dojox.wire.Wire: (prototype)
      • dojox.wire.Wire: (call)
    • summary
      Initialize properties
    • description
      If 'dataStore' property is not specified, but 'parent' property
      is specified, 'dataStore' property is copied from the parent.
    • parameters:
      • args: (typeof Object)
        Arguments to initialize properties
    • source: [view]
        if(!this.dataStore && this.parent){
         this.dataStore = this.parent.dataStore;
        }
  • dojox.wire.DataWire._wireClass

    • summary
  • dojox.wire.DataWire._getValue

    • type
      Function
    • parameters:
      • object: (typeof Object)
        A root item
    • source: [view]
        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
    • 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.
    • return_summary
      A value found, otherwise 'undefined'
    • returns
      Object|undefined|anything
  • dojox.wire.DataWire._setValue

    • type
      Function
    • parameters:
      • object: (typeof Object)
        A root item
      • value: (typeof anything)
        A value to set
    • source: [view]
        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
    • 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.
    • return_summary
      'object', or 'undefined' for invalid attribute
    • returns
      Object|undefined
  • dojox.wire.DataWire._getAttributeValue

    • type
      Function
    • parameters:
      • item: (typeof Object)
        An item
        attribute
        An attribute name
      • attribute: (typeof String)
    • source: [view]
        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
    • 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.
    • return_summary
      A value found, otherwise 'undefined'
    • returns
      return array for "attribute[]"|anything
  • dojox.wire.DataWire._setAttributeValue

    • type
      Function
    • parameters:
      • item: (typeof Object)
        An item
      • attribute: (typeof String)
        An attribute name
      • value: (typeof anything)
        A value to set
    • source: [view]
        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);
        }
    • 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.
  • dojox.wire.DataWire.dataStore

    • type
      A
    • summary
      data store
      attribute:
      A dotted notation to a descendant attribute
  • dojox.wire

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary