Article Discussion
Two-Way Data Binding in Flex 4
Summary: Data binding is among the most common UI programming tasks. Although the open-source Flex framework has supported data binding since its inception, the latest Flex 4 SDK adds two-way data binding as well. This tutorial illustrates two-way data binding in Flex 4.
10 posts on 1 page.      
« Previous 1 Next »
The ability to add new comments in this discussion is temporarily disabled.
Most recent reply: August 6, 2010 8:56 PM by Loren
Bill
Posts: 409 / Nickname: bv / Registered: January 17, 2002 4:28 PM
Two-Way Data Binding in Flex 4
July 28, 2009 9:00 PM      
Data binding is among the most common UI programming tasks. Although the open-source Flex framework has supported data binding since its inception, the latest Flex 4 SDK adds two-way data binding as well. This tutorial illustrates two-way data binding in Flex 4.

http://www.artima.com/articles/two_way_binding.html

What do you think of the approach to data binding presented in the article?
Ken
Posts: 3 / Nickname: kenonartim / Registered: August 12, 2009 8:31 AM
Re: Two-Way Data Binding in Flex 4
August 12, 2009 1:41 PM      
Data [Binding] is evil 'magic' and should be avoided by anyone who can program a solution instead. I realize this needs to exist for the non-programmers, but anyone who has an alternative should use it (if you want to have scalable and maintainable code) --- this comment arises from bitter experience of debugging [Bindable].
Ian
Posts: 12 / Nickname: ianr / Registered: April 20, 2007 6:37 AM
Re: Two-Way Data Binding in Flex 4
August 14, 2009 6:40 AM      
> Data [Binding] is evil 'magic' and should be avoided by
> anyone who can program a solution instead. I realize this
> needs to exist for the non-programmers, but anyone who has
> an alternative should use it (if you want to have scalable
> and maintainable code) --- this comment arises from bitter
> experience of debugging [Bindable].

I would be interested in hearing more about this. Data binding seems to be a key language feature for Flex - perhaps the single most important feature from a UI standpoint. What sorts of debugging issues have you seen with it?
Roman
Posts: 1 / Nickname: romanb / Registered: February 14, 2008 7:18 AM
Re: Two-Way Data Binding in Flex 4
August 15, 2009 1:05 PM      
> Data [Binding] is evil 'magic' and should be avoided by
> anyone who can program a solution instead. I realize this
> needs to exist for the non-programmers, but anyone who has
> an alternative should use it (if you want to have scalable
> and maintainable code) --- this comment arises from bitter
> experience of debugging [Bindable].

I assume you're only referring to Flex here and not Data Binding in general because Data Binding in .NET 3.x / WPF is pretty good and a key feature.
Ken
Posts: 3 / Nickname: kenonartim / Registered: August 12, 2009 8:31 AM
Re: Two-Way Data Binding in Flex 4
August 17, 2009 10:50 AM      
Yes, I am only referring to Flex.
Ken
Posts: 3 / Nickname: kenonartim / Registered: August 12, 2009 8:31 AM
Re: Two-Way Data Binding in Flex 4
August 17, 2009 11:00 AM      
I have several times debugged problems where a 'cascade' of [Bindable] was used --- one [Bindable] triggers another [Bindable] etc., the final bindables were used to control features of columns in an advanced data grid. If you trace [Binadble] through the debug player, you will see that it does a 'LOT' of work. With a complex enough situation the Flex runtime can take longer than the server timeout (30 minutes) to return.

I have many situation with complex usage of [Bindable] that do work, but there is a limit to how complex the usage can be.

In the situations where I had problems, simply removing [Bindable] and explicitly setting values solved the problem.

I find that often [Bindable] is simply used as the 'easiest way', which is fine in small applications, but in a large 'mission critical' application you can get into a very difficult to detect problem, which if the code is being maintained months after it was written or being maintained by someone other than the original coder can be problematic.
Rob
Posts: 1 / Nickname: robrusher / Registered: August 18, 2009 2:18 AM
Re: Two-Way Data Binding in Flex 4
August 18, 2009 7:24 AM      
Having only glanced at binding in WPF, how is it any different?
It appears that both Flex and XAML provide binding as a short cut to coding repetitive methods that handle data changes.
Frederic
Posts: 1 / Nickname: fredericc / Registered: October 5, 2009 3:56 AM
Re: Two-Way Data Binding in Flex 4
October 5, 2009 9:06 AM      
Hello,

I'm quite familiar with Eclise Data Binding framework:
http://wiki.eclipse.org/index.php/JFace_Data_Binding

but quite new to Flex.

IMHO beside converters, a complete data binding framework requires the following features:

- onChange validation
- ability to track the validity status of multiple fields within a form to know if the whole form is valid or not.

Can you give to hints if those feature are available in Flex 3 or will be available in Flex 4 ?
Loren
Posts: 2 / Nickname: ljamese / Registered: August 6, 2010 3:46 PM
Re: Two-Way Data Binding in Flex 4
August 6, 2010 8:53 PM      
Is this supposed to work for binding between AS and MXML objects? For example, I have an AS object like this:

public class Foo {
[Bindable]
public var bar:String;
}

and an MXML class like this (abbreviated):

<s:Group...>
<s:TextInput id="someId"/>
</s:Group>

An instance of foo is provided to the MXML component via a code-behind page. I have tried binding foo.bar to someId.text in various ways, and it doesn't seem to work exactly. Meaning that if I change foo.bar then someId.text will change, but the reverse doesn't work.

I've tried binding with:

<fx:Binding source="foo.bar" destination="someId.text" twoWay="true"/>

no workie, and:

<s:TextInput id="someId" text="@{foo.bar}"/>

still no workie. Any ideas?
Loren
Posts: 2 / Nickname: ljamese / Registered: August 6, 2010 3:46 PM
Re: Two-Way Data Binding in Flex 4
August 6, 2010 8:56 PM      
Bad form to reply to my own post, I know, but I also need to say that the compiler spits out a warning that "data binding will not be able to detect assignments to 'someId'.". What gives?
10 posts on 1 page.
« Previous 1 Next »