123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- if(!dojo._hasResource["dojox.wire.ml.Data"]){
- dojo._hasResource["dojox.wire.ml.Data"] = true;
- dojo.provide("dojox.wire.ml.Data");
- dojo.provide("dojox.wire.ml.DataProperty");
- dojo.require("dijit._Widget");
- dojo.require("dijit._Container");
- dojo.require("dojox.wire.ml.util");
- dojo.declare("dojox.wire.ml.Data", [dijit._Widget, dijit._Container], {
-
-
-
-
-
-
- startup: function(){
-
-
-
-
- this._initializeProperties();
- },
- _initializeProperties: function(/*Boolean*/reset){
-
-
-
-
-
-
-
-
- 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){
-
-
-
-
-
-
-
-
-
- return this._properties[property];
- },
- setPropertyValue: function(/*String*/property, /*anything*/value){
-
-
-
-
-
-
-
-
-
- this._properties[property] = value;
- }
- });
- dojo.declare("dojox.wire.ml.DataProperty", [dijit._Widget, dijit._Container], {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- name: "",
- type: "",
- value: "",
- _getValueAttr: function(){
- return this.getValue();
- },
- getValue: function(){
-
-
-
-
-
-
-
-
- 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;
- }
- });
- }
|