Skip to content

Looks like Flex data binding is not bidirectional

I have a AS3 class Loan that is being fetched from the server and the whole Loan class is marked as [Bindable]

Now in the Form I have a: <mx:TextInput text=”{currenLoan.loanAmount}” />
The problem is that user modifies the text in the textInput, it does not automatically update the variable that the control is bound to. I’m not sure if it is supported by Flex though, as I have this expectation from XForms.

As the solution to the problem I had to define the binding as <mx:Binding source=”{myTextInput.text}” destination=”{currentLoan.loanAmount}” /> So then any changes in the TextInput are being committed to the original loan object.

I wonder if there are any better, elegant solutions to this?

technorati tags: flex binding ria

5 Comments

  1. Luxspes wrote:

    Hi!
    And… after you added you removed or you kept both of them? (Do you need both of them for bidirectional databinding?)
    Thanks
    by

    Monday, August 6, 2007 at 3:55 pm | Permalink
  2. Luxspes wrote:

    Mmmm… your blog “ate” part of my post… I trying to ask you if you used both “mx:TextInput text=”{currenLoan.loanAmount}”” and “mx:Binding source=”{myTextInput.text}” destination=”{currentLoan.loanAmount}”” to enable bidirectional binding… or you used only one of them…

    Monday, August 6, 2007 at 3:57 pm | Permalink
  3. alexey wrote:

    Luxspes, I believed I used both to make sure that bidirectional binding works.

    Monday, August 6, 2007 at 9:43 pm | Permalink
  4. Radu wrote:

    The binding should not be bidirectional by default, imagine situations where you need to do some validation on the fields before applying the changes.

    just my 50 cents :)

    Sunday, November 18, 2007 at 11:33 pm | Permalink
  5. Doug wrote:

    Hi,
    Thanks for posting. It actually helps me to solve the issue.
    But the way you use the syntax is wrong. According to Flex 3 documentation, the curly bracket “{” and “}” are not needed in the “source” and “destination” declaration.
    Regards,
    Doug

    Monday, April 28, 2008 at 9:59 am | Permalink

Post a Comment

You must be logged in to post a comment.