I'm currently refactoring a small application to be more MVC and am running
into a few binding issues.
In my Model, I store all my dataProviders, which are Arrays (because they
will not change) and I also have a typed object that stores my form state as
individual objects. In my View, which is mostly a bunch of ComboBoxes, I
have set the dataProvider to bind to the arrays in the Model, and set the
selectedItem to bind to the form state properties. I added a button which
will update the form state for one of the properties when clicked, which
works (the ComboBox updates to the expected value) the first time, but not
on subsequent clicks. I've attached a listener to the valueCommit event on
the ComboBox, and it does fire the first time.
I've tried changing the Model to use ArrayCollections instead, and used the
Collection API to try and update the selectedItem (by setting the form state
model to the value of a getItem() call) but that isn't working either.
Is there a better way to handle storing and binding form state in a well
designed Flex app? I'm not using a framework, and don't really want to at
this point in time (the app is fairly small, and the deadline is approaching
quickly.)
Any help or insight is greatly appreciated!
- Ken
Code snippets:
The ComboBox:
<mx:FormItem label="Age">
<mx:ComboBox id="age" dataProvider="{model.ageList}" rowCount="10"
selectedItem="{model.quotingFormState.age}" />
</mx:FormItem>
The function called to update the ComboBox (works on first click only):
private function updateAge():void {
model.quotingFormState.age = model.ageList[5];
}