Just conceptually: Model: <?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:XML id="accidentsGeneral" format="e4x"> <general> <dateofaccident>{dateofaccident.text} </dateofaccident> <otherrailroadinvolved> {otherrailroadinvolved.selectedItem.data}</otherrailroadinvolved> <otherfilenumber>{dateofaccident.text} </otherfilenumber> <railroadrespfortrack> {dateofaccident.selectedItem.data}</railroadrespfortrack> </general> </mx:XML> </mx:Application>
Form: ... xmlns:moduleCode="accidents.ModuleCode.*" .... <mx:Form x="218.5" y="0" width="450" height="606" borderStyle="outset" id="frmGeneral"> <mx:FormItem label="Date of Accident (dd/mm/yyyy)"> <mx:DateField dataProvider="{accidentsGeneral.dateofaccident}" id="dateofaccident"/> </mx:FormItem> <mx:FormItem label="Other RailRoad Involved" width="356"> <mx:ComboBox dataProvider="{accidentsGeneral.otherrailroadinvolved}" id="otherrailroadinvolved"></mx:ComboBox> </mx:FormItem> <mx:FormItem label="File Number"> <mx:TextInput text="{accidentsGeneral.otherfilenumber}" id="otherfilenumber" width="72"/> </mx:FormItem> <mx:FormItem label="RailRoad Responsible For Track"> <mx:ComboBox dataProvider="{accidentsGeneral.railroadrespfortrack}" id="railroadrespfortrack"></mx:ComboBox> </mx:FormItem> .... data assignment: accidentsGeneral = event.result as XML; --- In flexcoders@yahoogroups.com, "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > I can't understand what you have from your description. Post the > relevant code snippets. > > Tracy > > > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of mark goldin > Sent: Wednesday, January 02, 2008 1:34 PM > To: flexcoders@yahoogroups.com > Subject: RE: [flexcoders] Re: Two way binding > > > > Alright. Is the following correct: > > Inside of a model I have it nodes bound to form items. In the form I > have it items bound to model's nodes, and xmlmodelvar = event.result as > XML will pull data into the model as well as show int in the form's > controls? > > Tracy Spratt <[EMAIL PROTECTED]> wrote: > > The simplest is to declare an instance variable typed as XML: > > var _xmlEmployee:XML; > > Then assign the event.result as XML in a result handler: > > _xmlEmployee = event.result as XML; > > If you want to use the declarative style, do: > > <mx:XML id="xmlEmployee" /> > > And in the result handler, do: > > xmlEmployee = event.result as XML; > > Tracy > > > > ________________________________ > > > From: flexcoders@yahoogroups.com > [mailto:[EMAIL PROTECTED] On Behalf Of markgoldin_2000 > Sent: Wednesday, January 02, 2008 12:59 PM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Re: Two way binding > > Are you talking about something like this: > <?xml version="1.0"?> > <!-- Models\XMLBinding.mxml --> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml > <http://www.adobe.com/2006/mxml> "> > <mx:XML id="myEmployee" format="e4x"> > <employee> > <name> > <first>{firstName.text}</first> > <last>{lastName.text}</last> > </name> > <department>{department.text}</department> > <email>{email.text}</email> > </employee> > </mx:XML> > <mx:TextInput id="firstName"/> > <mx:TextInput id="lastName"/> > <mx:TextInput id="department"/> > <mx:TextInput id="email"/> > </mx:Application> > > If it is then how do I let data from the server into this model? > > --- In flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <tspratt@> > wrote: > > > > But don't use mx:Model, that creates the nested dynamic object > > structure > > I mentioned. > > > > > > > > Use mx:XML, or use an instance variable typed as XML, and > assign it > in a > > result handler. > > > > > > > > Tracy > > > > > > > > ________________________________ > > > > From: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > [mailto:flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> ] On > > Behalf Of mark goldin > > Sent: Monday, December 31, 2007 1:18 PM > > To: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > Subject: RE: [flexcoders] Two way binding > > > > > > > > Let me make sure I understand. > > > > You are talking about something like this: > > > > > > > > <?xml version="1.0"?> > > <!-- Models\ModelTagEmptyString.mxml --> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml > <http://www.adobe.com/2006/mxml> " > > layout="absolute"> > > <mx:Model id="employeemodel" source="httpmodelsource"> > > </mx:Model> > > </mx:Application> > > where httpmodelsource returns the following xml: > > > > > > > > <employees> > > <employee> > > <name>John Doe</name> > > <phone>555-777-66555</phone> > > <email>jdoe@</email> > > <active>true</active> > > </employee> > > <employee> > > <name>Jane Doe</name> > > <phone>555-777-66555</phone> > > <email>jndoe@</email> > > <active>true</active> > > </employee> > > </employees> > > > > > > > > Tracy Spratt <tspratt@> wrote: > > > > Simplicity. Less code. Maintainability. Standardization, > well > > known API. > > > > Note that in the scenario I describe, the simplicity produces > a > > dependency between the client data model and the data > transport. If > > someone changes the XML you are consuming, you will have to > change > the > > code. For some this is unacceptable and they require level of > > abstraction between the transport and the model. It is just up > to > your > > particular requirements. > > > > Tracy > > > > > > > > ________________________________ > > > > > > From: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > [mailto:flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> ] On Behalf Of mark goldin > > Sent: Monday, December 31, 2007 12:36 PM > > To: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > Subject: RE: [flexcoders] Two way binding > > > > Aha, I see. Why would you suggest am xml based model over a > > class based one? > > > > Tracy Spratt <tspratt@> wrote: > > > > By "dataModel", are you referring to the ShoppingCart > > class you posted? You have to put the data into it. Get the > data > from > > the server, however you wish, and in the result handler, > assign the > data > > to an instance of the data model class, using the methods or > properties > > it provides. Then bind the form elements to propeties in the > model. > > > > Now, I would suggest using an XML object instance as > the > > data model. In the result handler, assign the result xml to an > > instance > > variable typed as XML. Then bind the form elements to that: > > > > <mx:Text [EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]> ...?> > > > > Tracy > > > > > > > > ________________________________ > > > > > > From: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > [mailto:flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> ] On Behalf Of mark goldin > > Sent: Monday, December 31, 2007 11:45 AM > > To: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > Subject: RE: [flexcoders] Two way binding > > > > I am probably a complete dumb. But dataModel does not > > have dataProvider property. How do I pull data into model > then? > > > > Tracy Spratt <tspratt@> wrote: > > > > Or the short answer, the same way you got the > > data into the dataProvider for the DataGrid. > > > > Tracy > > > > > > > > ________________________________ > > > > > > From: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > [mailto:flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> ] On Behalf Of Douglas Knudsen > > Sent: Monday, December 31, 2007 10:22 AM > > To: flexcoders@yahoogroups.com > <mailto:flexcoders%40yahoogroups.com> > > Subject: Re: [flexcoders] Two way binding > > > > That's a wholly different thread. You would > use > > WebService, HTTPservice, or RemoteObject to perform some sort > of > server > > call. Take a look at the docs on these tags and also at the > examples on > > Adobe.com <http://adobe.com/ <http://adobe.com/> > . For a > ColdFusion based example, > you can > > check this out > > > > > http://www.acfug.org/index.cfm?fa=meetings.meetingdetail&EventID=177 > <http://www.acfug.org/index.cfm? fa=meetings.meetingdetail&EventID=177> > > <http://www.acfug.org/index.cfm? > <http://www.acfug.org/index.cfm?> > fa=meetings.meetingdetail&EventID=177> > > > > DK > > > > On Dec 31, 2007 10:14 AM, mark goldin > > <markgoldin_2000@ <mailto:markgoldin_2000@> > wrote: > > > > And how data from server gets into the Model? > > > > > > > > Douglas Knudsen <douglasknudsen@ > > <mailto:douglasknudsen@> > wrote: > > > > What's wrong with this? > > <mx:TextInput text="{ > > someReferenceToAModel.property }" /> > > > > Now, you can use the Binding tag to > bind > > the value in the above back to the source, your datagrid in > this > case, > > but its not really a good idea, though YMMV. > > > > DK > > > > On Dec 31, 2007 9:33 AM, > markgoldin_2000 > > <markgoldin_2000@ <mailto:markgoldin_2000@> > wrote: > > > > I am trying to figure out what both > ways > > of data binding are. > > Basically we have two subjects for > data > > binding: DataGrid and a Form. > > With DataGrid it is pretty clear: > > dataProvider. But with form? It > > does not have such a dataProvider > > property (Which is in my opinion it > > should have). So, what's a solution > for > > that? DataModel? Which it > > turn does not have dataProvider > either. > > But it does have a source. > > Source of what? Data? Ok, let's stick > to > > dataModel. But then I am > > reading that it's better to use > > class-based models. Here is an > > example of class-based model form > Help: > > package > > { > > > > [Bindable] > > public class ShoppingCart { > > public var items:Array = []; > > > > public var total:Number = 0; > > > > public var shippingCost:Number = 0; > > > > public function ShoppingCart() { > > } > > > > public function addItem(item:Object, > > qty:int = 1, > > index:int = 0):void { > > items.splice(index, 0, { id: item.id > > <http://item.id/ <http://item.id/> > , > > name: item.name <http://item.name/ <http://item.name/> > , > > description: item.description, > > image: item.image, > > price: item.price, > > qty: qty }); > > total += parseFloat(item.price) * qty; > > } > > > > public function > > removeItemAt(index:Number):void { > > total -= parseFloat(items > [index].price) > > * items[index].qty; > > items.splice(index, 1); > > if (getItemCount() == 0) > > shippingCost = 0; > > } > > > > public function getItemCount():int { > > return items.length; > > } > > > > public function getTotal():Number { > > return total; > > } > > } > > } > > > > Two questions: > > 1. How the data is getting into a > > picture here? > > 2. How am I using this model in my > mxml > > file? > > > > Sorry if I am asking something > obvious, > > but I am just having problem > > understanding why data-centric > > environment does not have a straight > > way of binding data both ways. All I > > would want is to assign a data > > source to my form and then specify > data > > fields for each control in > > the form. Simple as this. Is this > > possible in Flex? > > > > Thanks > > > > > > > > > > > > > > > > -- > > Douglas Knudsen > > http://www.cubicleman.com <http://www.cubicleman.com/> > > <http://www.cubicleman.com/ <http://www.cubicleman.com/> > > > this is my signature, like it? > > > > > > > > > > -- > > Douglas Knudsen > > http://www.cubicleman.com <http://www.cubicleman.com/> > > <http://www.cubicleman.com/ <http://www.cubicleman.com/> > > > this is my signature, like it? > > >