[flexcoders] Two way binding and stric mode compiler options
Hi Guys, Iam using one data grid in which in have written one inline selectedItem =@{employee} , it is throwing a strict mode compiler error. I dont want to change my compiler options .. Please help Thanks, with Regards, Jitendra Jain Software Engineer 91-9979960798
[flexcoders] Two way binding in Flex 4
Morning all (well it is here ;) ), One for the Adobe guys I think, though anyone who's dug around in the Flex 4 SDK can chip in! Flex 4's two way binding... does it create an breakable reference in the same way as MXML binding does just now? I'm trying to judge its usefulness, and Ted Patrick's comments on his blog have totally confused me! http://www.onflex.org/ted/2008/09/useweakreferencesboolean-false.php#com ment-6262590827069335129 Basically, will we be making the already bad memory leak problem worse by using the two way binding? Gk. Gregor Kiddie Senior Developer INPS Tel: 01382 564343 Registered address: The Bread Factory, 1a Broughton Street, London SW8 3QJ Registered Number: 1788577 Registered in the UK Visit our Internet Web site at www.inps.co.uk blocked::http://www.inps.co.uk/ The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of INPS or any of its affiliates. If you are not the intended recipient please contact is.helpd...@inps.co.uk
RE: [flexcoders] Two way binding
But if I use XML based model how do I assign data to it that I am pulling from the server? Tracy Spratt [EMAIL PROTECTED] 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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 12:36 PM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] 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] ? Tracy - From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 11:45 AM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] wrote: Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy - From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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. For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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, name: 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
RE: [flexcoders] Two way binding
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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 1:18 PM To: flexcoders@yahoogroups.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; layout=absolute mx:Model id=employeemodel source=httpmodelsource /mx:Model /mx:Application where httpmodelsource returns the following xml: employees employee nameJohn Doe/name phone555-777-66555/phone email[EMAIL PROTECTED]/email activetrue/active /employee employee nameJane Doe/name phone555-777-66555/phone email[EMAIL PROTECTED]/email activetrue/active /employee /employees Tracy Spratt [EMAIL PROTECTED] 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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 12:36 PM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 11:45 AM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] wrote: Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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/ . For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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
[flexcoders] Two way binding
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, name: 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
Re: [flexcoders] Two way binding
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 [EMAIL PROTECTED] 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, name: 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 this is my signature, like it?
Re: [flexcoders] Two way binding
And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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, name: 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 this is my signature, like it?
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. For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] wrote: And how data from server gets into the Model? *Douglas Knudsen [EMAIL PROTECTED]* 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 [EMAIL PROTECTED] 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, name: 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 this is my signature, like it? -- Douglas Knudsen http://www.cubicleman.com this is my signature, like it?
RE: [flexcoders] Two way binding
Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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. For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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/ , name: 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/ this is my signature, like it? -- Douglas Knudsen http://www.cubicleman.com http://www.cubicleman.com this is my signature, like it?
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 [EMAIL PROTECTED] wrote: Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy - From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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. For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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, name: 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 this is my signature, like it? -- Douglas Knudsen http://www.cubicleman.com this is my signature, like it?
RE: [flexcoders] Two way binding
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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 11:45 AM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] wrote: Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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/ . For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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/ , name: 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
RE: [flexcoders] Two way binding
Aha, I see. Why would you suggest am xml based model over a class based one? Tracy Spratt [EMAIL PROTECTED] 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] ? Tracy - From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 11:45 AM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] wrote: Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy - From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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. For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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, name: 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 this is my signature, like it? -- Douglas Knudsen http://www.cubicleman.com this is my signature, like it?
RE: [flexcoders] Two way binding
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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 12:36 PM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 11:45 AM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] wrote: Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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/ . For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 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
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; layout=absolute mx:Model id=employeemodel source=httpmodelsource /mx:Model /mx:Application where httpmodelsource returns the following xml: employees employee nameJohn Doe/name phone555-777-66555/phone email[EMAIL PROTECTED]/email activetrue/active /employee employee nameJane Doe/name phone555-777-66555/phone email[EMAIL PROTECTED]/email activetrue/active /employee /employees Tracy Spratt [EMAIL PROTECTED] 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:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 12:36 PM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] 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] ? Tracy - From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of mark goldin Sent: Monday, December 31, 2007 11:45 AM To: flexcoders@yahoogroups.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 [EMAIL PROTECTED] wrote: Or the short answer, the same way you got the data into the dataProvider for the DataGrid. Tracy - From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Douglas Knudsen Sent: Monday, December 31, 2007 10:22 AM To: flexcoders@yahoogroups.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. For a ColdFusion based example, you can check this out http://www.acfug.org/index.cfm?fa=meetings.meetingdetailEventID=177 DK On Dec 31, 2007 10:14 AM, mark goldin [EMAIL PROTECTED] wrote: And how data from server gets into the Model? Douglas Knudsen [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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, name: 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
[flexcoders] Two-Way Binding Solutions?
I have trying to figure out how best to accomplish the two-way data binding needed for form entry. Here is what I thought would work, but it doesn't seem to: ON MODEL: I created two variables that hold my VO. model.pendingContact model.newContact The user clicks a button to get ContactVO data from the server. In the command class I assign the result (which is a typed PHP ContactVO) to each variable: model.pendingContact = data.result; model.newContact = data.result; I then bind my form fields to model.pendingContact so that the existing values from the server show up in the TextInput fields. Lastly, I use the BindingUtil methods to bind the text property of the TextInput fields back to model.newContact so that I can record any changes and send them back to the server. When the user submits the form, model.pendingContact should hold the old values model.newContact should have the new values. Correct?? Am I overlooking something. The only way I can get this to work is if I don't assign model.newContact to the values from the server and instead create a new instance like this: model.pendingContact = data.result; model.newContact = new ContactVO; However, I can't do this because I need the newContact to start out with the old values from the server. Is there a duplicate or clone object method that I need to use so that both model variables can be assigned to the same object from the server?? Thanks for the help. - Kevin
Re: [flexcoders] Two-Way Binding Solutions?
i think my problem boils down to one of object cloning. Does anyone have a good solution for deep cloning objects in AS3? Seems like this would be a pretty useful utility. - Kevin On Mar 26, 2007, at 1:50 PM, Kevin wrote: I have trying to figure out how best to accomplish the two-way data binding needed for form entry. Here is what I thought would work, but it doesn't seem to: ON MODEL: I created two variables that hold my VO. model.pendingContact model.newContact The user clicks a button to get ContactVO data from the server. In the command class I assign the result (which is a typed PHP ContactVO) to each variable: model.pendingContact = data.result; model.newContact = data.result; I then bind my form fields to model.pendingContact so that the existing values from the server show up in the TextInput fields. Lastly, I use the BindingUtil methods to bind the text property of the TextInput fields back to model.newContact so that I can record any changes and send them back to the server. When the user submits the form, model.pendingContact should hold the old values model.newContact should have the new values. Correct?? Am I overlooking something. The only way I can get this to work is if I don't assign model.newContact to the values from the server and instead create a new instance like this: model.pendingContact = data.result; model.newContact = new ContactVO; However, I can't do this because I need the newContact to start out with the old values from the server. Is there a duplicate or clone object method that I need to use so that both model variables can be assigned to the same object from the server?? Thanks for the help. - Kevin
RE: [flexcoders] Two-Way Binding Solutions?
mx.utils.ObjectUtil. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Sent: Monday, March 26, 2007 11:52 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Two-Way Binding Solutions? i think my problem boils down to one of object cloning. Does anyone have a good solution for deep cloning objects in AS3? Seems like this would be a pretty useful utility. - Kevin On Mar 26, 2007, at 1:50 PM, Kevin wrote: I have trying to figure out how best to accomplish the two-way data binding needed for form entry. Here is what I thought would work, but it doesn't seem to: ON MODEL: I created two variables that hold my VO. model.pendingContact model.newContact The user clicks a button to get ContactVO data from the server. In the command class I assign the result (which is a typed PHP ContactVO) to each variable: model.pendingContact = data.result; model.newContact = data.result; I then bind my form fields to model.pendingContact so that the existing values from the server show up in the TextInput fields. Lastly, I use the BindingUtil methods to bind the text property of the TextInput fields back to model.newContact so that I can record any changes and send them back to the server. When the user submits the form, model.pendingContact should hold the old values model.newContact should have the new values. Correct?? Am I overlooking something. The only way I can get this to work is if I don't assign model.newContact to the values from the server and instead create a new instance like this: model.pendingContact = data.result; model.newContact = new ContactVO; However, I can't do this because I need the newContact to start out with the old values from the server. Is there a duplicate or clone object method that I need to use so that both model variables can be assigned to the same object from the server?? Thanks for the help. - Kevin
RE: [flexcoders] Two-Way Binding Solutions?
To make a copy use: newContact = ObjectUtils.copy( pendingContact ); You can definitly work with it as you wrote below or use FDS which can do this for you :) Dimitrios Gianninas Developer Optimal Payments Inc. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Sent: Monday, March 26, 2007 1:51 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Two-Way Binding Solutions? I have trying to figure out how best to accomplish the two-way data binding needed for form entry. Here is what I thought would work, but it doesn't seem to: ON MODEL: I created two variables that hold my VO. model.pendingContact model.newContact The user clicks a button to get ContactVO data from the server. In the command class I assign the result (which is a typed PHP ContactVO) to each variable: model.pendingContact = data.result; model.newContact = data.result; I then bind my form fields to model.pendingContact so that the existing values from the server show up in the TextInput fields. Lastly, I use the BindingUtil methods to bind the text property of the TextInput fields back to model.newContact so that I can record any changes and send them back to the server. When the user submits the form, model.pendingContact should hold the old values model.newContact should have the new values. Correct?? Am I overlooking something. The only way I can get this to work is if I don't assign model.newContact to the values from the server and instead create a new instance like this: model.pendingContact = data.result; model.newContact = new ContactVO; However, I can't do this because I need the newContact to start out with the old values from the server. Is there a duplicate or clone object method that I need to use so that both model variables can be assigned to the same object from the server?? Thanks for the help. - Kevin -- WARNING --- This electronic message and its attachments may contain confidential, proprietary or legally privileged information, which is solely for the use of the intended recipient. No privilege or other rights are waived by any unintended transmission or unauthorized retransmission of this message. If you are not the intended recipient of this message, or if you have received it in error, you should immediately stop reading this message and delete it and all attachments from your system. The reading, distribution, copying or other use of this message or its attachments by unintended recipients is unauthorized and may be unlawful. If you have received this e-mail in error, please notify the sender. AVIS IMPORTANT -- Ce message électronique et ses pièces jointes peuvent contenir des renseignements confidentiels, exclusifs ou légalement privilégiés destinés au seul usage du destinataire visé. L'expéditeur original ne renonce à aucun privilège ou à aucun autre droit si le présent message a été transmis involontairement ou s'il est retransmis sans son autorisation. Si vous n'êtes pas le destinataire visé du présent message ou si vous l'avez reçu par erreur, veuillez cesser immédiatement de le lire et le supprimer, ainsi que toutes ses pièces jointes, de votre système. La lecture, la distribution, la copie ou tout autre usage du présent message ou de ses pièces jointes par des personnes autres que le destinataire visé ne sont pas autorisés et pourraient être illégaux. Si vous avez reçu ce courrier électronique par erreur, veuillez en aviser l'expéditeur.
Re: [flexcoders] Two-Way Binding Solutions?
thanks. this works great. To make a copy use: newContact = ObjectUtils.copy( pendingContact ); - Kevin