The Artima Developer Community
Sponsored Link

Articles Forum
Two-Way Data Binding in Flex 4

9 replies on 1 page. Most recent reply: Aug 7, 2010 12:56 AM by Loren Erickson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 9 replies on 1 page
Bill Venners

Posts: 2248
Nickname: bv
Registered: Jan, 2002

Two-Way Data Binding in Flex 4 Posted: Jul 29, 2009 1:00 AM
Reply to this message Reply
Advertisement
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: Aug, 2009

Re: Two-Way Data Binding in Flex 4 Posted: Aug 12, 2009 5:41 PM
Reply to this message Reply
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 Robertson

Posts: 68
Nickname: ianr
Registered: Apr, 2007

Re: Two-Way Data Binding in Flex 4 Posted: Aug 14, 2009 10:40 AM
Reply to this message Reply
> 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 Borschel

Posts: 3
Nickname: romanb
Registered: Feb, 2008

Re: Two-Way Data Binding in Flex 4 Posted: Aug 15, 2009 5:05 PM
Reply to this message Reply
> 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: Aug, 2009

Re: Two-Way Data Binding in Flex 4 Posted: Aug 17, 2009 2:50 PM
Reply to this message Reply
Yes, I am only referring to Flex.

Ken .

Posts: 3
Nickname: kenonartim
Registered: Aug, 2009

Re: Two-Way Data Binding in Flex 4 Posted: Aug 17, 2009 3:00 PM
Reply to this message Reply
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 Rusher

Posts: 1
Nickname: robrusher
Registered: Aug, 2009

Re: Two-Way Data Binding in Flex 4 Posted: Aug 18, 2009 11:24 AM
Reply to this message Reply
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 Conrotte

Posts: 1
Nickname: fredericc
Registered: Oct, 2009

Re: Two-Way Data Binding in Flex 4 Posted: Oct 5, 2009 1:06 PM
Reply to this message Reply
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 Erickson

Posts: 2
Nickname: ljamese
Registered: Aug, 2010

Re: Two-Way Data Binding in Flex 4 Posted: Aug 7, 2010 12:53 AM
Reply to this message Reply
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 Erickson

Posts: 2
Nickname: ljamese
Registered: Aug, 2010

Re: Two-Way Data Binding in Flex 4 Posted: Aug 7, 2010 12:56 AM
Reply to this message Reply
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?

Flat View: This topic has 9 replies on 1 page
Topic: Fills in Flex 4: It's What's on the Inside that Counts Previous Topic   Next Topic Topic: Stroke of Genius: Drawing Lines in Flex 4


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us