RE: [flexcoders] Binding Model to selectedItem property not updating
The code for a bindable property looks like function set someProperty(value:Object):void { if (value != someProperty) { dispatchEvent(new PropertyChangeEvent()) } } I left some stuff out, but basically, if the value doesn't change, there is no new event so no more processing. That's why in most cases you can update the model based on changes made in the view and you won't loop forever. Me, I wouldn't use two-way bindng, I'd just attach listeners to the view and update the model. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Ken Dunnington Sent: Friday, May 16, 2008 11:54 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Binding Model to selectedItem property not updating Thanks Alex, I realized continuously setting the value to ageList[5] was pointless since it didn't change, and I made my form state model extend EventDispatcher, which made it possible to listen for propertyChange events being fired. But I am still trying to find information on the best way to handle binding a form's state in a more MVC style. Do I need to attach listeners to each of my form controls to manually update the state in my model each time the form changes? If my form control's selectedItem is bound to that same state model, will that cause an infinite loop of bindings firing one after the other? I've been unable to find examples of binding a form to a model beyond the very simple (and tightly coupled) examples in the Flex docs, or of two-way binding in general. On Fri, May 16, 2008 at 2:14 PM, Alex Harui <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: If the value of model.ageList[5] does not change, no change event will be fired, and if quotingFormState doesn't dispatch change events for changes to the "age" property binding won't work then either. From: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> ] On Behalf Of Ken Dunnington Sent: Friday, May 16, 2008 8:19 AM To: flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> Subject: [flexcoders] Binding Model to selectedItem property not updating 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: The function called to update the ComboBox (works on first click only): private function updateAge():void { model.quotingFormState.age = model.ageList[5]; } -- The American Republic will endure until the day Congress discovers that it can bribe the public with the public's money. -- Alexis de Tocqueville
Re: [flexcoders] Binding Model to selectedItem property not updating
Thanks Pedro,I know of Cairngorm but unfortunately don't have time to factor it in on this project. I think I'll sort of fudge it with some BindingUtils calls for now, and start using a framework on the next app. :) I'm very interested in trying out Mate (http://mate.asfusion.com/) On Fri, May 16, 2008 at 3:11 PM, Pedro Sena <[EMAIL PROTECTED]> wrote: > Hi Ken, > > Do you know the Cairngorm framework ? > > It does what you want, and in this link you will find some intersting > tutorials: > > http://www.davidtucker.net/category/cairngorm/ > > C ya > > On Fri, May 16, 2008 at 3:54 PM, Ken Dunnington <[EMAIL PROTECTED]> > wrote: > >> Thanks Alex, I realized continuously setting the value to ageList[5] >> was pointless since it didn't change, and I made my form state model extend >> EventDispatcher, which made it possible to listen for propertyChange events >> being fired. >> >> But I am still trying to find information on the best way to handle >> binding a form's state in a more MVC style. Do I need to attach listeners to >> each of my form controls to manually update the state in my model each time >> the form changes? If my form control's selectedItem is bound to that same >> state model, will that cause an infinite loop of bindings firing one after >> the other? I've been unable to find examples of binding a form to a model >> beyond the very simple (and tightly coupled) examples in the Flex docs, or >> of two-way binding in general. >> >> On Fri, May 16, 2008 at 2:14 PM, Alex Harui <[EMAIL PROTECTED]> wrote: >> >>>If the value of model.ageList[5] does not change, no change event >>> will be fired, and if quotingFormState doesn't dispatch change events for >>> changes to the "age" property binding won't work then either. >>> >>> ---------- >>> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On >>> Behalf Of *Ken Dunnington >>> *Sent:* Friday, May 16, 2008 8:19 AM >>> *To:* flexcoders@yahoogroups.com >>> *Subject:* [flexcoders] Binding Model to selectedItem property not >>> updating >>> >>> 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: >>> >>> >>> >>> >> >>> selectedItem="{model.quotingFormState.age}" /> >>> >>> >>> >>> >>> The function called to update the ComboBox (works on first click only): >>> >>> private function updateAge():void { >>> >>> model.quotingFormState.age = model.ageList[5]; >>> >>> } >>> >>> >> >> >> -- >> The American Republic will endure until the day Congress discovers that it >> can bribe the public with the public's money. >> -- Alexis de Tocqueville >> > > > > -- > /** > * Pedro Sena > * System Architect > * Sun Certified Java Programmer > * Sun Certified Web Component Developer > */ > > > -- The American Republic will endure until the day Congress discovers that it can bribe the public with the public's money. -- Alexis de Tocqueville
Re: [flexcoders] Binding Model to selectedItem property not updating
Hi Ken, Do you know the Cairngorm framework ? It does what you want, and in this link you will find some intersting tutorials: http://www.davidtucker.net/category/cairngorm/ C ya On Fri, May 16, 2008 at 3:54 PM, Ken Dunnington <[EMAIL PROTECTED]> wrote: > Thanks Alex, I realized continuously setting the value to ageList[5] was > pointless since it didn't change, and I made my form state model extend > EventDispatcher, which made it possible to listen for propertyChange events > being fired. > > But I am still trying to find information on the best way to handle binding > a form's state in a more MVC style. Do I need to attach listeners to each of > my form controls to manually update the state in my model each time the form > changes? If my form control's selectedItem is bound to that same state > model, will that cause an infinite loop of bindings firing one after the > other? I've been unable to find examples of binding a form to a model beyond > the very simple (and tightly coupled) examples in the Flex docs, or of > two-way binding in general. > > On Fri, May 16, 2008 at 2:14 PM, Alex Harui <[EMAIL PROTECTED]> wrote: > >>If the value of model.ageList[5] does not change, no change event will >> be fired, and if quotingFormState doesn't dispatch change events for changes >> to the "age" property binding won't work then either. >> >> -- >> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On >> Behalf Of *Ken Dunnington >> *Sent:* Friday, May 16, 2008 8:19 AM >> *To:* flexcoders@yahoogroups.com >> *Subject:* [flexcoders] Binding Model to selectedItem property not >> updating >> >> 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: >> >> >> >> > >> selectedItem="{model.quotingFormState.age}" /> >> >> >> >> >> The function called to update the ComboBox (works on first click only): >> >> private function updateAge():void { >> >> model.quotingFormState.age = model.ageList[5]; >> >> } >> >> > > > -- > The American Republic will endure until the day Congress discovers that it > can bribe the public with the public's money. > -- Alexis de Tocqueville > > -- /** * Pedro Sena * System Architect * Sun Certified Java Programmer * Sun Certified Web Component Developer */
Re: [flexcoders] Binding Model to selectedItem property not updating
Thanks Alex, I realized continuously setting the value to ageList[5] was pointless since it didn't change, and I made my form state model extend EventDispatcher, which made it possible to listen for propertyChange events being fired. But I am still trying to find information on the best way to handle binding a form's state in a more MVC style. Do I need to attach listeners to each of my form controls to manually update the state in my model each time the form changes? If my form control's selectedItem is bound to that same state model, will that cause an infinite loop of bindings firing one after the other? I've been unable to find examples of binding a form to a model beyond the very simple (and tightly coupled) examples in the Flex docs, or of two-way binding in general. On Fri, May 16, 2008 at 2:14 PM, Alex Harui <[EMAIL PROTECTED]> wrote: >If the value of model.ageList[5] does not change, no change event will > be fired, and if quotingFormState doesn't dispatch change events for changes > to the "age" property binding won't work then either. > > -- > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Ken Dunnington > *Sent:* Friday, May 16, 2008 8:19 AM > *To:* flexcoders@yahoogroups.com > *Subject:* [flexcoders] Binding Model to selectedItem property not > updating > > 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: > > > > > selectedItem="{model.quotingFormState.age}" /> > > > > > The function called to update the ComboBox (works on first click only): > > private function updateAge():void { > > model.quotingFormState.age = model.ageList[5]; > > } > > > -- The American Republic will endure until the day Congress discovers that it can bribe the public with the public's money. -- Alexis de Tocqueville
RE: [flexcoders] Binding Model to selectedItem property not updating
If the value of model.ageList[5] does not change, no change event will be fired, and if quotingFormState doesn't dispatch change events for changes to the "age" property binding won't work then either. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Ken Dunnington Sent: Friday, May 16, 2008 8:19 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Binding Model to selectedItem property not updating 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: The function called to update the ComboBox (works on first click only): private function updateAge():void { model.quotingFormState.age = model.ageList[5]; }
[flexcoders] Binding Model to selectedItem property not updating
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: The function called to update the ComboBox (works on first click only): private function updateAge():void { model.quotingFormState.age = model.ageList[5]; }