more fixes for databinding
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/286147c1 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/286147c1 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/286147c1 Branch: refs/heads/develop Commit: 286147c15f3c309de9108000fcd473c6db907d47 Parents: 132a29b Author: Alex Harui <aha...@apache.org> Authored: Tue Jun 25 22:41:41 2013 -0700 Committer: Alex Harui <aha...@apache.org> Committed: Tue Jun 25 22:46:40 2013 -0700 ---------------------------------------------------------------------- .../org/apache/flex/core/ViewBaseDataBinding.as | 4 +-- .../org/apache/flex/core/ViewBaseDataBinding.js | 38 ++++++++++++++------ 2 files changed, 29 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/286147c1/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as ---------------------------------------------------------------------- diff --git a/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as b/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as index 0d5b876..2761295 100644 --- a/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as +++ b/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as @@ -83,7 +83,7 @@ package org.apache.flex.core else { deferredBindings[binding.destination[0]] = sb; - IEventDispatcher(_strand).addEventListener("propertyChange", deferredBindingsHandler); + IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler); } } else if (fieldWatcher.eventNames == null) @@ -99,7 +99,7 @@ package org.apache.flex.core else { deferredBindings[binding.destination[0]] = cb; - IEventDispatcher(_strand).addEventListener("propertyChange", deferredBindingsHandler); + IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler); } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/286147c1/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js index 5f7b5d0..7a94187 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js @@ -61,7 +61,7 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.set_strand = org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler = function(event) { - var bindingData = this.strand_["_bindings"]; + var bindingData = this.strand_['_bindings']; var n = bindingData[0]; var bindings = []; var i; @@ -80,10 +80,10 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler = if (binding.source != null) { // try to determine if it is an array - if (typeof(binding.source) == "object" && - typeof(binding.source.slice) == "function") + if (typeof(binding.source) == 'object' && + typeof(binding.source.slice) == 'function') { - if (binding.source[0] == "applicationModel") + if (binding.source[0] == 'applicationModel') { if (binding.source.length == 2 && binding.destination.length == 2) @@ -91,10 +91,10 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler = var destination; // can be simplebinding or constantbinding var modelWatcher = - watchers.watcherMap["applicationModel"]; + watchers.watcherMap['applicationModel']; var childMap = modelWatcher.children.watcherMap var fieldWatcher = childMap[binding.source[1]]; - if (typeof(fieldWatcher.eventNames) == "string") + if (typeof(fieldWatcher.eventNames) == 'string') { var sb; sb = new org.apache.flex.binding.SimpleBinding(); @@ -106,13 +106,18 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler = sb.setDocument(this.strand_); destination = this.strand_[ binding.destination[0]]; + if (destination == null && + typeof(this.strand_['get_' + + binding.destination[0]] == 'function')) + destination = this.strand_[ + 'get_' + binding.destination[0]](); if (destination) destination.addBead(sb); else { this.deferredBindings[binding.destination[0]] = sb; - this.strand_.addEventListener("propertyChange", + this.strand_.addEventListener('valueChange', this.deferredBindingsHandler); } } @@ -128,13 +133,18 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler = cb.setDocument(this.strand_); destination = this.strand_[ binding.destination[0]]; + if (destination == null && + typeof(this.strand_['get_' + + binding.destination[0]] == 'function')) + destination = this.strand_[ + 'get_' + binding.destination[0]](); if (destination) destination.addBead(cb); else { this.deferredBindings[binding.destination[0]] = cb; - this.strand_.addEventListener("propertyChange", + this.strand_.addEventListener('valueChange', this.deferredBindingsHandler); } } @@ -167,7 +177,7 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.decodeWatcher = { case 0: { - watcherData = { type: "function" }; + watcherData = { type: 'function' }; watcherData.functionName = bindingData[index++]; watcherData.eventNames = bindingData[index++]; watcherData.bindings = bindingData[index++]; @@ -176,7 +186,7 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.decodeWatcher = case 1: case 2: { - watcherData = { type: type == 1 ? "static" : "property" }; + watcherData = { type: type == 1 ? 'static' : 'property' }; watcherData.propertyName = bindingData[index++]; watcherData.eventNames = bindingData[index++]; watcherData.bindings = bindingData[index++]; @@ -186,7 +196,7 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.decodeWatcher = } case 3: { - watcherData = { type: "xml" }; + watcherData = { type: 'xml' }; watcherData.propertyName = bindingData[index++]; watcherData.bindings = bindingData[index++]; watcherMap[watcherData.propertyName] = watcherData; @@ -220,6 +230,12 @@ function(event) { destination.addBead(this.deferredBindings[p]); delete deferredBindings[p]; } + else if (typeof(this.strand_['get_' + p]) == 'function') + { + var destination = this.strand_['get_' + p](); + destination.addBead(this.deferredBindings[p]); + delete deferredBindings[p]; + } } };