You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/07/09 21:20:58 UTC

git commit: [flex-asjs] [refs/heads/develop] - Changes to get generic expression binding to work

Updated Branches:
  refs/heads/develop 65dd0552b -> ff20b3321


Changes to get generic expression binding to work


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/ff20b332
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/ff20b332
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/ff20b332

Branch: refs/heads/develop
Commit: ff20b33214585290f018a7ee238ad5bfc9951e65
Parents: 65dd055
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jul 9 12:04:46 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Jul 9 12:20:39 2013 -0700

----------------------------------------------------------------------
 .../org/apache/flex/binding/GenericBinding.as   | 111 +++++++++
 .../org/apache/flex/binding/PropertyWatcher.as  | 156 ++++++++++++
 .../org/apache/flex/binding/SimpleBinding.as    |   5 +-
 .../src/org/apache/flex/binding/WatcherBase.as  | 236 +++++++++++++++++++
 .../org/apache/flex/core/ViewBaseDataBinding.as | 148 +++++++++---
 .../src/org/apache/flex/binding/BindingBase.js  |  33 ++-
 .../org/apache/flex/binding/GenericBinding.js   | 123 ++++++++++
 .../org/apache/flex/binding/PropertyWatcher.js  | 176 ++++++++++++++
 .../org/apache/flex/binding/SimpleBinding.js    |   7 -
 .../src/org/apache/flex/binding/WatcherBase.js  | 222 +++++++++++++++++
 .../org/apache/flex/core/ViewBaseDataBinding.js | 193 +++++++++++----
 .../org/apache/flex/events/ValueChangeEvent.js  |  38 ++-
 12 files changed, 1342 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/as/src/org/apache/flex/binding/GenericBinding.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/binding/GenericBinding.as b/frameworks/as/src/org/apache/flex/binding/GenericBinding.as
new file mode 100644
index 0000000..b86c0ab
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/binding/GenericBinding.as
@@ -0,0 +1,111 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.binding
+{	
+	import flash.events.Event;
+	
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IDocument;
+	import org.apache.flex.core.IStrand;
+
+	public class GenericBinding implements IBead, IDocument
+	{
+		public function GenericBinding()
+		{
+		}
+		
+		protected var document:Object;
+        protected var destination:Object;
+
+		public var source:Object;
+		public var destinationData:Object;
+		
+		public function set strand(value:IStrand):void
+		{
+			destination = value;
+            var val:Object = getValueFromSource();
+            applyValue(val);
+        }
+        
+        private function getValueFromSource():Object
+        {
+            if (source is Array)
+            {
+                var arr:Array = source as Array;
+                var n:int = arr.length;
+                var obj:Object = document[arr[0]];
+                if (obj == null)
+                    return null;
+                for (var i:int = 1; i < n; i++)
+                {
+                    obj = obj[arr[i]];
+                    if (obj == null)
+                        return null;
+                }
+                return obj;
+            }
+            else if (source is Function)
+            {
+                var fn:Function = source as Function;
+                obj = fn.apply(document);
+                return obj;
+            }
+            else if (source is String)
+            {
+                obj = document[source];
+                return obj;
+            }
+            return null;
+		}
+        
+        private function applyValue(value:Object):void
+        {
+            if (destinationData is Array)
+            {
+                var arr:Array = destinationData as Array;
+                var n:int = arr.length;
+                var obj:Object = document[arr[0]];
+                if (obj == null)
+                    return;
+                for (var i:int = 1; i < n - 1; i++)
+                {
+                    obj = obj[arr[i]];
+                    if (obj == null)
+                        return;
+                }
+                obj[arr[n-1]] = value;                
+            }
+            else if (destinationData is Function)
+            {
+                Function(destinationData).apply(document, [value]);
+            }
+        }
+		
+		public function setDocument(document:Object, id:String = null):void
+		{
+			this.document = document;
+		}
+		
+		public function valueChanged(value:Object):void
+		{
+            var val:Object = getValueFromSource();
+            applyValue(val);
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/as/src/org/apache/flex/binding/PropertyWatcher.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/binding/PropertyWatcher.as b/frameworks/as/src/org/apache/flex/binding/PropertyWatcher.as
new file mode 100644
index 0000000..bde39e6
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/binding/PropertyWatcher.as
@@ -0,0 +1,156 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.binding
+{	
+    import org.apache.flex.events.Event;
+    import org.apache.flex.events.IEventDispatcher;
+    import org.apache.flex.events.ValueChangeEvent;
+
+	public class PropertyWatcher extends WatcherBase
+	{
+		public function PropertyWatcher(source:Object, propertyName:String, eventNames:Object, 
+                                            getterFunction:Function)
+		{
+            this.source = source;
+            this.propertyName = propertyName;
+            this.getterFunction = getterFunction;
+            this.eventNames = eventNames;
+            
+		}
+		
+		public var source:Object;
+        public var propertyName:String;
+        public var eventNames:Object;
+        public var getterFunction:Function;
+		
+        protected function changeHandler(event:Event):void
+        {
+            if (event is ValueChangeEvent)
+            {
+                var propName:String = ValueChangeEvent(event).propertyName;
+                
+                if (propName != propertyName)
+                    return;
+            }
+            
+            wrapUpdate(updateProperty);
+            
+            notifyListeners();
+            
+        }
+        
+        //--------------------------------------------------------------------------
+        //
+        //  Overridden methods: Watcher
+        //
+        //--------------------------------------------------------------------------
+        
+        /**
+         *  If the parent has changed we need to update ourselves
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        override public function parentChanged(parent:Object):void
+        {
+            if (source && source is IEventDispatcher)
+                removeEventListeners();
+
+            source = parent;
+            
+            if (source)
+                addEventListeners();
+            
+            // Now get our property.
+            wrapUpdate(updateProperty);
+        }
+
+        private function addEventListeners():void
+        {
+            if (eventNames is String)
+                source.addEventListener(eventNames as String, changeHandler);
+            else if (eventNames is Array)
+            {
+                var arr:Array = eventNames as Array;
+                var n:int = arr.length;
+                for (var i:int = 0; i < n; i++)
+                {
+                    var eventName:String = eventNames[i];
+                    source.addEventListener(eventName, changeHandler);           
+                }
+            }
+        }
+        
+        private function removeEventListeners():void
+        {
+            if (eventNames is String)
+                source.removeEventListener(eventNames as String, changeHandler);
+            else if (eventNames is Array)
+            {
+                var arr:Array = eventNames as Array;
+                var n:int = arr.length;
+                for (var i:int = 0; i < n; i++)
+                {
+                    var eventName:String = eventNames[i];
+                    source.removeEventListener(eventName, changeHandler);           
+                }
+            }
+        }
+        
+        /**
+         *  Gets the actual property then updates
+         *  the Watcher's children appropriately.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        private function updateProperty():void
+        {
+            if (source)
+            {
+                if (propertyName == "this")
+                {
+                    value = source;
+                }
+                else
+                {
+                    if (getterFunction != null)
+                    {
+                        value = getterFunction.apply(source, [ propertyName ]);
+                    }
+                    else
+                    {
+                        value = source[propertyName];
+                    }
+                }
+            }
+            else
+            {
+                value = null;
+            }
+            
+            updateChildren();
+        }
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/as/src/org/apache/flex/binding/SimpleBinding.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/binding/SimpleBinding.as b/frameworks/as/src/org/apache/flex/binding/SimpleBinding.as
index 6e5a72a..bab9378 100644
--- a/frameworks/as/src/org/apache/flex/binding/SimpleBinding.as
+++ b/frameworks/as/src/org/apache/flex/binding/SimpleBinding.as
@@ -43,7 +43,10 @@ package org.apache.flex.binding
 		public function set strand(value:IStrand):void
 		{
 			destination = value;
-			source = document[sourceID] as IEventDispatcher;
+            if (sourceID != null)
+    			source = document[sourceID] as IEventDispatcher;
+            else
+                source = document as IEventDispatcher;
 			source.addEventListener(eventName, changeHandler);
 			destination[destinationPropertyName] = source[sourcePropertyName];
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/as/src/org/apache/flex/binding/WatcherBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/binding/WatcherBase.as b/frameworks/as/src/org/apache/flex/binding/WatcherBase.as
new file mode 100644
index 0000000..47d4286
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/binding/WatcherBase.as
@@ -0,0 +1,236 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package org.apache.flex.binding
+{
+    
+    public class WatcherBase
+    {
+        //--------------------------------------------------------------------------
+        //
+        //  Constructor
+        //
+        //--------------------------------------------------------------------------
+        
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        public function WatcherBase()
+        {
+            super();
+        }
+        
+        //--------------------------------------------------------------------------
+        //
+        //  Variables
+        //
+        //--------------------------------------------------------------------------
+        
+        /**
+         *  @private
+         *  The binding objects that are listening to this Watcher.
+         *  The standard event mechanism isn't used because it's too heavyweight.
+         */
+        protected var listeners:Array;
+        
+        /**
+         *  @private
+         *  Children of this watcher are watching sub values.
+         */
+        protected var children:Array;
+        
+        /**
+         *  @private
+         *  The value itself.
+         */
+        public var value:Object;
+        
+        //--------------------------------------------------------------------------
+        //
+        //  Methods
+        //
+        //--------------------------------------------------------------------------
+        
+        /**
+         *  @private
+         *  This is an abstract method that subclasses implement.
+         */
+        public function parentChanged(parent:Object):void
+        {
+        }
+        
+        /**
+         *  @private
+         *  Add a child to this watcher, meaning that the child
+         *  is watching a sub value of ours.
+         */
+        public function addChild(child:WatcherBase):void
+        {
+            if (!children)
+                children = [ child ];
+            else
+                children.push(child);
+            
+            child.parentChanged(this);
+        }
+        
+        /**
+         *  @private
+         *  Add a binding to this watcher, meaning that the binding
+         *  is notified when our value changes.
+         */
+        public function addBinding(binding:GenericBinding):void
+        {
+            if (!listeners)
+                listeners = [ binding ];
+            else
+                listeners.push(binding);
+            
+            binding.valueChanged(value);
+        }
+                
+        /**
+         *  We have probably changed, so go through
+         *  and make sure our children are updated.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Flex 3
+         */
+        public function updateChildren():void
+        {
+            if (children)
+            {
+                var n:int = children.length;
+                for (var i:int = 0; i < n; ++i)
+                {
+                    children[i].parentChanged(this);
+                }
+            }
+        }
+        
+        /**
+         *  @private
+         */
+        private function valueChanged(oldval:Object):Boolean
+        {
+            if (oldval == null && value == null)
+                return false;
+            
+            var valType:String = typeof(value);
+            
+            // The first check is meant to catch the delayed instantiation case
+            // where a control comes into existence but its value is still
+            // the equivalent of not having been filled in.
+            // Otherwise we simply return whether the value has changed.
+            
+            if (valType == "string")
+            {
+                if (oldval == null && value == "")
+                    return false;
+                else
+                    return oldval != value;
+            }
+            
+            if (valType == "number")
+            {
+                if (oldval == null && value == 0)
+                    return false;
+                else
+                    return oldval != value;
+            }
+            
+            if (valType == "boolean")
+            {
+                if (oldval == null && value == false)
+                    return false;
+                else
+                    return oldval != value;
+            }
+            
+            return true;
+        }
+        
+        /**
+         *  @private
+         */
+        protected function wrapUpdate(wrappedFunction:Function):void
+        {
+            try
+            {
+                wrappedFunction.apply(this);
+            }
+            catch(error:Error)
+            {
+                var n:int = allowedErrorTypes.length;
+                for (var i:int = 0; i < n; i++)
+                {
+                    if (error is allowedErrorTypes[i].type)
+                    {
+                        var handler:Function = allowedErrorTypes[i].handler;
+                        if (handler != null)
+                            value = handler(this, wrappedFunction);
+                        else
+                            value = null;
+                    }
+                }
+                
+                if (allowedErrors.indexOf(error.errorID) == -1)
+                    throw error;
+            }
+        }
+        
+        // Certain errors are normal when executing an update, so we swallow them:
+        public static var allowedErrors:Array = [
+            1006, //   Error #1006: Call attempted on an object that is not a function.
+            1009, //   Error #1009: null has no properties.
+            1010, //   Error #1010: undefined has no properties.
+            1055, //   Error #1055: - has no properties.
+            1069, //   Error #1069: Property - not found on - and there is no default value
+            1507 //   Error #1507: - invalid null argument.
+            ];
+        
+        public static var allowedErrorTypes:Array = [
+            { type: RangeError /*, handler: function(w:WatcherBase, wrappedFunction:Function):Object { return null }*/ }
+            ];
+        
+        /**
+         *  @private
+         */
+        public function notifyListeners():void
+        {
+            if (listeners)
+            {
+                var n:int = listeners.length;
+                
+                for (var i:int = 0; i < n; i++)
+                {
+                    listeners[i].valueChanged(value);
+                }
+            }
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/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 2761295..75901d0 100644
--- a/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as
+++ b/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as
@@ -19,7 +19,10 @@
 package org.apache.flex.core
 {
     import org.apache.flex.binding.ConstantBinding;
+    import org.apache.flex.binding.GenericBinding;
+    import org.apache.flex.binding.PropertyWatcher;
     import org.apache.flex.binding.SimpleBinding;
+    import org.apache.flex.binding.WatcherBase;
     import org.apache.flex.core.IBead;
     import org.apache.flex.core.IStrand;
     import org.apache.flex.events.Event;
@@ -41,6 +44,8 @@ package org.apache.flex.core
 
         private function initCompleteHandler(event:Event):void
         {
+            var fieldWatcher:Object;
+            var sb:SimpleBinding;
             var bindingData:Array = _strand["_bindings"];
             var n:int = bindingData[0];
             var bindings:Array = [];
@@ -56,56 +61,123 @@ package org.apache.flex.core
             var watchers:Object = decodeWatcher(bindingData.slice(index));
             for (i = 0; i < n; i++)
             {
-                binding = bindings[i];
-                if (binding.source != null)
+                    binding = bindings[i];
+                if (binding.source is Array)
                 {
-                    if (binding.source is Array)
+                    if (binding.source[0] == "applicationModel")
                     {
-                        if (binding.source[0] == "applicationModel")
+                        if (binding.source.length == 2 && binding.destination.length == 2)
                         {
-                            if (binding.source.length == 2 && binding.destination.length == 2)
+                            var destination:IStrand;
+                            // can be simplebinding or constantbinding
+                            var modelWatcher:Object = watchers.watcherMap["applicationModel"];
+                            fieldWatcher = modelWatcher.children.watcherMap[binding.source[1]];
+                            if (fieldWatcher.eventNames is String)
                             {
-                                var destination:IStrand;
-                                // can be simplebinding or constantbinding
-                                var modelWatcher:Object = watchers.watcherMap["applicationModel"];
-                                var fieldWatcher:Object = modelWatcher.children.watcherMap[binding.source[1]];
-                                if (fieldWatcher.eventNames is String)
+                                sb = new SimpleBinding();
+                                sb.destinationPropertyName = binding.destination[1];
+                                sb.eventName = fieldWatcher.eventNames as String;
+                                sb.sourceID = binding.source[0];
+                                sb.sourcePropertyName = binding.source[1];
+                                sb.setDocument(_strand);
+                                destination = _strand[binding.destination[0]] as IStrand;
+                                if (destination)
+                                    destination.addBead(sb);
+                                else
                                 {
-                                    var sb:SimpleBinding = new SimpleBinding();
-                                    sb.destinationPropertyName = binding.destination[1];
-                                    sb.eventName = fieldWatcher.eventNames as String;
-                                    sb.sourceID = binding.source[0];
-                                    sb.sourcePropertyName = binding.source[1];
-                                    sb.setDocument(_strand);
-                                    destination = _strand[binding.destination[0]] as IStrand;
-                                    if (destination)
-                                        destination.addBead(sb);
-                                    else
-                                    {
-                                        deferredBindings[binding.destination[0]] = sb;
-                                        IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler);
-                                    }
+                                    deferredBindings[binding.destination[0]] = sb;
+                                    IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler);
                                 }
-                                else if (fieldWatcher.eventNames == null)
+                            }
+                            else if (fieldWatcher.eventNames == null)
+                            {
+                                var cb:ConstantBinding = new ConstantBinding();
+                                cb.destinationPropertyName = binding.destination[1];
+                                cb.sourceID = binding.source[0];
+                                cb.sourcePropertyName = binding.source[1];
+                                cb.setDocument(_strand);
+                                destination = _strand[binding.destination[0]] as IStrand;
+                                if (destination)
+                                    destination.addBead(cb);
+                                else
                                 {
-                                    var cb:ConstantBinding = new ConstantBinding();
-                                    cb.destinationPropertyName = binding.destination[1];
-                                    cb.sourceID = binding.source[0];
-                                    cb.sourcePropertyName = binding.source[1];
-                                    cb.setDocument(_strand);
-                                    destination = _strand[binding.destination[0]] as IStrand;
-                                    if (destination)
-                                        destination.addBead(cb);
-                                    else
-                                    {
-                                        deferredBindings[binding.destination[0]] = cb;
-                                        IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler);
-                                    }
+                                    deferredBindings[binding.destination[0]] = cb;
+                                    IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler);
                                 }
                             }
                         }
                     }
                 }
+                else if (binding.source is String)
+                {
+                    fieldWatcher = watchers.watcherMap[binding.source];
+                    if (fieldWatcher.eventNames is String)
+                    {
+                        sb = new SimpleBinding();
+                        sb.destinationPropertyName = binding.destination[1];
+                        sb.eventName = fieldWatcher.eventNames as String;
+                        sb.sourcePropertyName = binding.source;
+                        sb.setDocument(_strand);
+                        destination = _strand[binding.destination[0]] as IStrand;
+                        if (destination)
+                            destination.addBead(sb);
+                        else
+                        {
+                            deferredBindings[binding.destination[0]] = sb;
+                            IEventDispatcher(_strand).addEventListener("valueChange", deferredBindingsHandler);
+                        }
+                    }
+                }
+                else
+                {
+                    makeGenericBinding(binding, i, watchers);
+                }
+            }
+        }
+
+        private function makeGenericBinding(binding:Object, index:int, watchers:Object):void
+        {
+            var gb:GenericBinding = new GenericBinding();
+            gb.setDocument(_strand);
+            gb.destinationData = binding.destination;
+            gb.source = binding.source;
+            setupWatchers(gb, index, watchers.watchers, null);
+        }
+        
+        private function setupWatchers(gb:GenericBinding, index:int, watchers:Array, parentWatcher:WatcherBase):void
+        {
+            var n:int = watchers.length;
+            for (var i:int = 0; i < n; i++)
+            {
+                var watcher:Object = watchers[i];
+                if (watcher.bindings.indexOf(index) != -1)
+                {
+                    var type:String = watcher.type;
+                    switch (type)
+                    {
+                        case "property":
+                        {
+                            var pw:PropertyWatcher = new PropertyWatcher(this, 
+                                        watcher.propertyName, 
+                                        watcher.eventNames,
+                                        watcher.getterFunction);
+                            watcher.watcher = pw;
+                            if (parentWatcher)
+                                pw.parentChanged(parentWatcher.value);
+                            else
+                                pw.parentChanged(_strand);
+                            if (parentWatcher)
+                                parentWatcher.addChild(pw);
+                            if (watcher.children == null)
+                                pw.addBinding(gb);
+                            break;
+                        }
+                    }
+                    if (watcher.children)
+                    {
+                        setupWatchers(gb, index, watcher.children, watcher.watcher);
+                    }
+                }
             }
         }
         

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
index 980e161..058ed41 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/BindingBase.js
@@ -20,13 +20,14 @@ goog.provide('org.apache.flex.binding.BindingBase');
  * @constructor
  */
 org.apache.flex.binding.BindingBase = function() {
-  /**
-   * @private
-   * @type {Object}
-   */
-  this.document_ = null;
 };
 
+/**
+ * @protected
+ * @type {Object}
+ */
+org.apache.flex.binding.BindingBase.prototype.document = null;
+
 
 /**
  * @expose
@@ -57,17 +58,29 @@ org.apache.flex.binding.BindingBase.prototype.sourcePropertyName = '';
 
 
 /**
+ * @expose
+ * @type {string}
+ */
+org.apache.flex.binding.BindingBase.prototype.sourceID;
+
+
+/**
  * @this {org.apache.flex.binding.BindingBase}
  * @param {Object} value The strand (owner) of the bead.
  */
 org.apache.flex.binding.BindingBase.prototype.set_strand = function(value) {
   this.destination = value;
 
-  try {
-    this.source = this.document_['get_' + this.sourceID]();
-  } catch (e) {
-    this.source = this.document_[this.sourceID];
+  if (this.sourceID != null)
+  {
+    try {
+        this.source = this.document['get_' + this.sourceID]();
+    } catch (e) {
+        this.source = this.document[this.sourceID];
+    }
   }
+  else
+    this.source = this.document;
 };
 
 
@@ -76,5 +89,5 @@ org.apache.flex.binding.BindingBase.prototype.set_strand = function(value) {
  * @param {Object} document The MXML object.
  */
 org.apache.flex.binding.BindingBase.prototype.setDocument = function(document) {
-  this.document_ = document;
+  this.document = document;
 };

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js
new file mode 100644
index 0000000..36d293f
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js
@@ -0,0 +1,123 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('org.apache.flex.binding.GenericBinding');
+goog.require('org.apache.flex.binding.BindingBase');
+
+/**
+ * @constructor
+ */
+org.apache.flex.binding.GenericBinding = function() {
+};
+goog.inherits(org.apache.flex.binding.GenericBinding,
+    org.apache.flex.binding.BindingBase);
+
+
+/**
+ * @expose
+ * @type {Object}
+ */
+org.apache.flex.binding.GenericBinding.prototype.destinationData = null;
+
+/**
+ * @expose
+ * @this {org.apache.flex.binding.GenericBinding}
+ * @param {Object} value The strand (owner) of the bead.
+ */
+org.apache.flex.binding.GenericBinding.prototype.set_strand =
+            function(value) {
+  this.destination = value;
+
+  var val = this.getValueFromSource();
+  this.applyValue(val);
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.binding.GenericBinding}
+ * @return {Object} The value from the source as specified.
+ */
+org.apache.flex.binding.GenericBinding.prototype.getValueFromSource =
+            function() {
+    if (typeof(this.source) == 'object' &&
+        typeof(this.source.slice) == 'function')
+    {
+        var arr = this.source;
+        var n = arr.length;
+        var obj = this.document['get_' + arr[0]]();
+        if (obj == null)
+            return null;
+        for (var i = 1; i < n; i++)
+        {
+            obj = obj['get_' + arr[i]]();
+            if (obj == null)
+                return null;
+        }
+        return obj;
+    }
+    else if (typeof(this.source) == 'function')
+    {
+        var fn = this.source;
+        obj = fn.apply(this.document);
+        return obj;
+    }
+    else if (typeof(this.source) == 'string')
+    {
+        obj = this.document['get_' + this.source]();
+        return obj;
+    }
+    return null;
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.binding.GenericBinding}
+ * @param {Object} value The value from the source as specified.
+ */
+org.apache.flex.binding.GenericBinding.prototype.applyValue =
+        function(value)
+{
+    if (typeof(this.destinationData) == 'object')
+    {
+        var arr = this.destinationData;
+        var n = arr.length;
+        var obj = this.document['get_' + arr[0]]();
+        if (obj == null)
+            return;
+        for (var i = 1; i < n - 1; i++)
+        {
+            obj = obj['get_' + arr[i]]();
+            if (obj == null)
+                return;
+        }
+        obj['set_' + arr[n - 1]](value);
+    }
+    else if (typeof(this.destinationData) == 'function')
+    {
+        this.destinationData.apply(this.document, [value]);
+    }
+};
+
+/**
+ * @expose
+ * @this {org.apache.flex.binding.GenericBinding}
+ * @param {Object} value The value from the source as specified.
+ */
+org.apache.flex.binding.GenericBinding.prototype.valueChanged =
+        function(value)
+{
+    var val = this.getValueFromSource();
+    this.applyValue(val);
+};
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/js/FlexJS/src/org/apache/flex/binding/PropertyWatcher.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/PropertyWatcher.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/PropertyWatcher.js
new file mode 100644
index 0000000..205f7cc
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/PropertyWatcher.js
@@ -0,0 +1,176 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('org.apache.flex.binding.PropertyWatcher');
+goog.require('org.apache.flex.binding.WatcherBase');
+
+/**
+ * @constructor
+ * @param {Object} source The source object.
+ * @param {string} propertyName The property in the source.
+ * @param {Object} eventNames An array of event names or an event name.
+ * @param {function} getterFunction A function to get the source property.
+ */
+org.apache.flex.binding.PropertyWatcher =
+        function(source, propertyName, eventNames, getterFunction) {
+    this.source = source;
+    this.propertyName = propertyName;
+    this.getterFunction = getterFunction;
+    this.eventNames = eventNames;
+};
+goog.inherits(org.apache.flex.binding.PropertyWatcher,
+    org.apache.flex.binding.WatcherBase);
+
+
+/**
+ * @type {Object}
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.source;
+
+/**
+ * @type {string}
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.propertyName;
+
+/**
+ * @type {Object}
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.eventNames;
+
+/**
+ * @type {function}
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.getterFunction = null;
+
+/**
+ * @protected
+ * @this {org.apache.flex.binding.PropertyWatcher}
+ * @param {Object} event The event.
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.changeHandler =
+        function(event) {
+    if (typeof(event.propertyName) == 'string')
+    {
+        var propName = event.propertyName;
+
+        if (propName != this.propertyName)
+            return;
+    }
+
+    this.wrapUpdate(this.updateProperty);
+
+    this.notifyListeners();
+
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.binding.PropertyWatcher}
+ * @param {Object} parent The new parent watcher.
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.parentChanged =
+        function(parent) {
+
+    if (this.source && 
+        typeof(this.source.removeEventListener) == 'function')
+        this.removeEventListeners();
+
+    this.source = parent;
+
+    if (this.source)
+        this.addEventListeners();
+
+    // Now get our property.
+    this.wrapUpdate(this.updateProperty);
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.binding.PropertyWatcher}
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.addEventListeners =
+        function() {
+    if (typeof(this.eventNames) == 'string')
+        this.source.addEventListener(this.eventNames, 
+            goog.bind(this.changeHandler, this));
+    else if (typeof(this.eventNames) == 'Object')
+    {
+        var arr = this.eventNames;
+        var n = arr.length;
+        for (var i = 0; i < n; i++)
+        {
+            var eventName = this.eventNames[i];
+            this.source.addEventListener(eventName, 
+                goog.bind(this.changeHandler, this));
+        }
+    }
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.binding.PropertyWatcher}
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.removeEventListeners =
+        function() {
+    if (typeof(this.eventNames) == 'string')
+        this.source.removeEventListener(this.eventNames,
+                goog.bind(this.changeHandler, this));
+    else if (typeof(this.eventNames) == 'Object')
+    {
+        var arr = this.eventNames;
+        var n = arr.length;
+        for (var i = 0; i < n; i++)
+        {
+            var eventName = this.eventNames[i];
+            this.source.removeEventListener(eventName, 
+                goog.bind(this.changeHandler, this));
+        }
+    }
+};
+
+/**
+ * @protected
+ * Gets the actual property then updates
+ * the Watcher's children appropriately.
+ * @this {org.apache.flex.binding.PropertyWatcher}
+ */
+org.apache.flex.binding.PropertyWatcher.prototype.updateProperty =
+        function() {
+
+    if (this.source)
+    {
+        if (this.propertyName == 'this')
+        {
+            this.value = this.source;
+        }
+        else
+        {
+            if (this.getterFunction != null)
+            {
+                this.value = this.getterFunction.apply(
+                        this.source, [this.propertyName]);
+            }
+            else
+            {
+                this.value = this.source[this.propertyName];
+            }
+        }
+    }
+    else
+    {
+        this.value = null;
+    }
+
+    this.updateChildren();
+};

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
index 8bb3ed6..c46433c 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/SimpleBinding.js
@@ -36,13 +36,6 @@ org.apache.flex.binding.SimpleBinding.prototype.eventName = '';
 
 
 /**
- * @expose
- * @type {string}
- */
-org.apache.flex.binding.SimpleBinding.prototype.sourceID = '';
-
-
-/**
  * @this {org.apache.flex.binding.SimpleBinding}
  */
 org.apache.flex.binding.SimpleBinding.prototype.changeHandler = function() {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/js/FlexJS/src/org/apache/flex/binding/WatcherBase.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/WatcherBase.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/WatcherBase.js
new file mode 100644
index 0000000..2ccbe40
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/WatcherBase.js
@@ -0,0 +1,222 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('org.apache.flex.binding.WatcherBase');
+
+/**
+ * @constructor
+ */
+org.apache.flex.binding.WatcherBase = function() {
+
+    /**
+     * @protected
+     * @type {Object}
+     */
+    this.listeners;
+
+    /**
+     * @protected
+     * @type {Object}
+     * Children of this watcher are watching sub values.
+     */
+    this.children;
+};
+
+/**
+ *  @expose
+ *  The value itself.
+ */
+org.apache.flex.binding.WatcherBase.prototype.value;
+
+/**
+ *  @expose
+ *  This is an abstract method that subclasses implement.
+ *  @this {org.apache.flex.binding.WatcherBase}
+ *  @param {Object} parent The new parent.
+ */
+org.apache.flex.binding.WatcherBase.prototype.parentChanged =
+        function(parent) {
+};
+
+/**
+ *  @expose
+ *  Add a child to this watcher, meaning that the child
+ *  is watching a sub value of ours.
+ *  @this {org.apache.flex.binding.WatcherBase}
+ *  @param {Object} child The new child.
+ */
+org.apache.flex.binding.WatcherBase.prototype.addChild =
+        function(child) {
+    if (!this.children)
+        this.children = [child];
+    else
+        this.children.push(child);
+
+    child.parentChanged(this);
+};
+
+/**
+ *  @expose
+ *  Add a binding to this watcher, meaning that the binding
+ *  is notified when our value changes.
+ *  @this {org.apache.flex.binding.WatcherBase}
+ *  @param {Object} binding The new binding.
+ */
+org.apache.flex.binding.WatcherBase.prototype.addBinding =
+        function(binding) {
+    if (!this.listeners)
+        this.listeners = [binding];
+    else
+        this.listeners.push(binding);
+
+    binding.valueChanged(this.value);
+};
+
+/**
+ *  @expose
+ *  @this {org.apache.flex.binding.WatcherBase}
+ *  We have probably changed, so go through
+ *  and make sure our children are updated.
+ */
+org.apache.flex.binding.WatcherBase.prototype.updateChildren = function() {
+    if (this.children)
+    {
+        var n = this.children.length;
+        for (var i = 0; i < n; ++i)
+        {
+            this.children[i].parentChanged(this);
+        }
+    }
+};
+
+/**
+ *  @protected
+ *  @this {org.apache.flex.binding.WatcherBase}
+ *  @param {Object} oldValue The prior value.
+ *  @return {boolean} True if value changed.
+ */
+org.apache.flex.binding.WatcherBase.prototype.valueChanged =
+            function(oldValue) {
+
+    if (oldValue == null && this.value == null)
+        return false;
+
+    var valType = typeof(this.value);
+
+    // The first check is meant to catch the delayed instantiation case
+    // where a control comes into existence but its value is still
+    // the equivalent of not having been filled in.
+    // Otherwise we simply return whether the value has changed.
+
+    if (valType == 'string')
+    {
+        if (oldValue == null && this.value == '')
+            return false;
+        else
+            return oldValue != this.value;
+    }
+
+    if (valType == 'number')
+    {
+        if (oldValue == null && this.value == 0)
+            return false;
+        else
+            return oldValue != this.value;
+    }
+
+    if (valType == 'boolean')
+    {
+        if (oldValue == null && this.value == false)
+            return false;
+        else
+            return oldValue != this.value;
+    }
+
+    return true;
+};
+
+/**
+ *  @protected
+ *  @this {org.apache.flex.binding.WatcherBase}
+ *  @param {function} wrappedFunction The function to call.
+ */
+org.apache.flex.binding.WatcherBase.prototype.wrapUpdate =
+        function(wrappedFunction) {
+    try
+    {
+        wrappedFunction.apply(this);
+    }
+    catch (error)
+    {
+        var staticClass = org.apache.flex.binding.WatcherBase;
+        var n = this.allowedErrorTypes.length;
+        for (var i = 0; i < n; i++)
+        {
+            if (error.constructor == allowedErrorTypes[i].type)
+            {
+                var handler = staticClass.allowedErrorTypes[i].handler;
+                if (handler != null)
+                    this.value = handler(this, wrappedFunction);
+                else
+                    this.value = null;
+            }
+        }
+
+        if (staticClass.allowedErrors.indexOf(error.errorID) == -1)
+            throw error;
+    }
+};
+
+
+/**
+ * Certain errors are normal when executing an update, so we swallow them:
+ */
+org.apache.flex.binding.WatcherBase.allowedErrors = [
+            1006, //   Error #1006: Call attempted on an object
+                  //                that is not a function.
+            1009, //   Error #1009: null has no properties.
+            1010, //   Error #1010: undefined has no properties.
+            1055, //   Error #1055: - has no properties.
+            1069, //   Error #1069: Property - not found on - and
+                  //                there is no default value
+            1507 //   Error #1507: - invalid null argument.
+            ];
+
+/**
+ * Certain types of errors are normal when executing an update,
+ * so we custom handle them or swallow them:
+ */
+org.apache.flex.binding.WatcherBase.allowedErrorTypes = [
+            { type: RangeError /*,
+              handler: function(w:WatcherBase,
+                    wrappedFunction:Function):Object { return null }*/
+            }
+            ];
+
+/**
+ *  @protected
+ *  @this {org.apache.flex.binding.WatcherBase}
+ */
+org.apache.flex.binding.WatcherBase.prototype.notifyListeners = function()
+{
+    if (this.listeners)
+    {
+        var n = this.listeners.length;
+
+        for (var i = 0; i < n; i++)
+        {
+            this.listeners[i].valueChanged(this.value);
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/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 7a94187..c47233b 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js
@@ -14,11 +14,13 @@
 
 goog.provide('org.apache.flex.core.ViewBaseDataBinding');
 
+goog.require('org.apache.flex.binding.PropertyWatcher');
 goog.require('org.apache.flex.binding.ConstantBinding');
+goog.require('org.apache.flex.binding.GenericBinding');
 goog.require('org.apache.flex.binding.SimpleBinding');
 goog.require('org.apache.flex.events.Event');
 
-    
+
 /**
  * @constructor
  */
@@ -31,13 +33,13 @@ org.apache.flex.core.ViewBaseDataBinding = function() {
   this.strand_ = null;
 
   /**
-   * @private
+   * @protected
    * @type {Object}
    */
   this.deferredBindings = {};
 
 };
-        
+
 /**
  * @expose
  * @this {org.apache.flex.core.ViewBaseDataBinding}
@@ -61,6 +63,8 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.set_strand =
 org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler =
     function(event) {
 
+    var fieldWatcher;
+    var sb;
     var bindingData = this.strand_['_bindings'];
     var n = bindingData[0];
     var bindings = [];
@@ -77,84 +81,175 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler =
     for (i = 0; i < n; i++)
     {
         binding = bindings[i];
-        if (binding.source != null)
+        // try to determine if it is an array
+        if (typeof(binding.source) == 'object' &&
+            typeof(binding.source.slice) == 'function')
         {
-            // try to determine if it is an array
-            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)
                 {
-                    if (binding.source.length == 2 &&
-                        binding.destination.length == 2)
-                    {
-                        var destination;
-                        // can be simplebinding or constantbinding
-                        var modelWatcher = 
+                    var destination;
+                    // can be simplebinding or constantbinding
+                    var modelWatcher =
                             watchers.watcherMap['applicationModel'];
-                        var childMap = modelWatcher.children.watcherMap
-                        var fieldWatcher = childMap[binding.source[1]];
-                        if (typeof(fieldWatcher.eventNames) == 'string')
-                        {
-                          var sb;
-                          sb = new org.apache.flex.binding.SimpleBinding();
-                          sb.destinationPropertyName = 
+                    var childMap = modelWatcher.children.watcherMap;
+                    fieldWatcher = childMap[binding.source[1]];
+                    if (typeof(fieldWatcher.eventNames) == 'string')
+                    {
+                        sb = new org.apache.flex.binding.SimpleBinding();
+                        sb.destinationPropertyName =
                                     binding.destination[1];
-                          sb.eventName = fieldWatcher.eventNames;
-                          sb.sourceID = binding.source[0];
-                          sb.sourcePropertyName = binding.source[1];
-                          sb.setDocument(this.strand_);
-                          destination = this.strand_[
+                        sb.eventName = fieldWatcher.eventNames;
+                        sb.sourceID = binding.source[0];
+                        sb.sourcePropertyName = binding.source[1];
+                        sb.setDocument(this.strand_);
+                        destination = this.strand_[
                                             binding.destination[0]];
-                          if (destination == null && 
+                        if (destination == null &&
                                 typeof(this.strand_['get_' +
                                     binding.destination[0]] == 'function'))
                                 destination = this.strand_[
                                         'get_' + binding.destination[0]]();
-                          if (destination)
+                        if (destination)
                               destination.addBead(sb);
-                          else
-                          {
+                        else
+                        {
                             this.deferredBindings[binding.destination[0]] =
                                     sb;
                             this.strand_.addEventListener('valueChange',
                                     this.deferredBindingsHandler);
-                          }
                         }
-                        else if (fieldWatcher.eventNames == null)
-                        {
-                          var cb;
-                          cb = org.apache.flex.binding.ConstantBinding;
-                          cb = new cb();
-                          cb.destinationPropertyName = 
+                    }
+                    else if (fieldWatcher.eventNames == null)
+                    {
+                        var cb;
+                        cb = org.apache.flex.binding.ConstantBinding;
+                        cb = new cb();
+                        cb.destinationPropertyName =
                                 binding.destination[1];
-                          cb.sourceID = binding.source[0];
-                          cb.sourcePropertyName = binding.source[1];
-                          cb.setDocument(this.strand_);
-                          destination = this.strand_[
+                        cb.sourceID = binding.source[0];
+                        cb.sourcePropertyName = binding.source[1];
+                        cb.setDocument(this.strand_);
+                        destination = this.strand_[
                                             binding.destination[0]];
-                          if (destination == null && 
+                        if (destination == null &&
                                 typeof(this.strand_['get_' +
                                     binding.destination[0]] == 'function'))
                                 destination = this.strand_[
                                         'get_' + binding.destination[0]]();
-                          if (destination)
+                        if (destination)
                                 destination.addBead(cb);
-                          else
-                          {
+                        else
+                        {
                             this.deferredBindings[binding.destination[0]] =
                                 cb;
                             this.strand_.addEventListener('valueChange',
                                 this.deferredBindingsHandler);
-                          }
                         }
                     }
                 }
             }
         }
+        else if (typeof(binding.source) == 'string')
+        {
+            fieldWatcher = watchers.watcherMap[binding.source];
+            if (typeof(fieldWatcher.eventNames) == 'string')
+            {
+                sb = new org.apache.flex.binding.SimpleBinding();
+                sb.destinationPropertyName = binding.destination[1];
+                sb.eventName = fieldWatcher.eventNames;
+                sb.sourcePropertyName = binding.source;
+                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('valueChange',
+                                this.deferredBindingsHandler);
+                }
+            }
+        }
+        else
+        {
+            this.makeGenericBinding(binding, i, watchers);
+        }
     }
 };
-        
+
+
+/**
+ * @protected
+ * @this {org.apache.flex.core.ViewBaseDataBinding}
+ * @param {Object} binding The binding object.
+ * @param {number} index The offset in the Binding database.
+ * @param {Object} watchers The database of Watchers.
+ */
+org.apache.flex.core.ViewBaseDataBinding.prototype.makeGenericBinding =
+        function(binding, index, watchers) {
+    var gb = new org.apache.flex.binding.GenericBinding();
+    gb.setDocument(this.strand_);
+    gb.destinationData = binding.destination;
+    gb.source = binding.source;
+    this.setupWatchers(gb, index, watchers.watchers, null);
+};
+
+/**
+ * @protected
+ * @this {org.apache.flex.core.ViewBaseDataBinding}
+ * @param {Object} gb The generic binding object.
+ * @param {number} index The offset in the Binding database.
+ * @param {Object} watchers The array of Watchers.
+ * @param {Object} parentWatcher The parent Watcher or null if top.
+ */
+org.apache.flex.core.ViewBaseDataBinding.prototype.setupWatchers =
+        function(gb, index, watchers, parentWatcher) {
+    var i, n;
+    n = watchers.length;
+    for (i = 0; i < n; i++)
+    {
+        var watcher = watchers[i];
+        if (watcher.bindings.indexOf(index) != -1)
+        {
+            var type = watcher.type;
+            switch (type)
+            {
+                case 'property':
+                {
+                    var pw = new org.apache.flex.binding.PropertyWatcher(
+                                this,
+                                watcher.propertyName,
+                                watcher.eventNames,
+                                watcher.getterFunction);
+                    watcher.watcher = pw;
+                    if (parentWatcher)
+                        pw.parentChanged(parentWatcher.value);
+                    else
+                        pw.parentChanged(this.strand_);
+                    if (parentWatcher)
+                        parentWatcher.addChild(pw);
+                    if (watcher.children == null)
+                        pw.addBinding(gb);
+                    break;
+                }
+            }
+            if (watcher.children)
+            {
+                this.setupWatchers(gb, index, watcher.children,
+                    watcher.watcher);
+            }
+        }
+    }
+};
+
 /**
  * @protected
  * @this {org.apache.flex.core.ViewBaseDataBinding}
@@ -210,10 +305,10 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.decodeWatcher =
         }
         watcherData.index = watcherIndex;
         watchers.push(watcherData);
-    }            
+    }
     return { watchers: watchers, watcherMap: watcherMap };
 };
-        
+
 /**
  * @protected
  * @this {org.apache.flex.core.ViewBaseDataBinding}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ff20b332/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js b/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js
index 45240b6..f73744b 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/events/ValueChangeEvent.js
@@ -60,6 +60,42 @@ org.apache.flex.events.ValueChangeEvent.prototype.oldValue = null;
 
 /**
  * @expose
- * @type {string} newValue The new value.
+ * @type {Object} newValue The new value.
  */
 org.apache.flex.events.ValueChangeEvent.prototype.newValue = null;
+
+/**
+ * @expose
+ * @type {string} propertyName The property that changed.
+ */
+org.apache.flex.events.ValueChangeEvent.prototype.propertyName = null;
+
+/**
+ * @expose
+ * @type {Object} source The object that changed.
+ */
+org.apache.flex.events.ValueChangeEvent.prototype.source = null;
+
+/**
+ * @expose
+ * @param {Object} source The object that changed.
+ * @param {string} name The property that changed.
+ * @param {Object} oldValue The old value.
+ * @param {Object} newValue The new value.
+ */
+org.apache.flex.events.ValueChangeEvent.createUpdateEvent =
+        function(source, name, oldValue, newValue)
+{
+    var event = new org.apache.flex.events.ValueChangeEvent(
+            org.apache.flex.events.ValueChangeEvent.VALUE_CHANGE, 
+            oldValue, newValue);
+    event.propertyName = name;
+    event.source = source;
+    return event;
+};
+
+/**
+ * @expose
+ * @type {string} VALUE_CHANGE The type of the event.
+ */
+org.apache.flex.events.ValueChangeEvent.VALUE_CHANGE = "valueChange";