mxml is xml (duh?)
april 23, 2008 at 4:04pm
in flex, flex for CF'ers
just a quickie today, something that i came across while playing around with flex. it could very well be a "duh, charlie" observation, but i think it bears mentioning.
flex makes it very easy to bind elements to other elements or objects. what this means is that a datagrid, for example, can be populated by the contents of an ArrayCollection (for CF'ers, think of an ArrayCollection as an array of structures). the first step is to declare the variable as bindable in your <mx:Script> block:
- [Bindable]
- private var myArray:ArrayCollection;
your DataGrid would then be declared as follows:
- <mx:DataGrid dataProvider="{myArray}" id="myDataGrid">
the curly braces around the value of the dataProvider attribute indicates that it's a bindable variable. all pretty straightforward. but there are other ways to use bind variables to influence the behavior of an element.
flex: Objects are like structures. kinda. (part ii)
april 18, 2008 at 1:34pm
in ColdFusion, flex, flex for CF'ers
last night i started documenting my journey of learning flex, focusing on my use of the built-in Object datatype and some issues that i faced in that respect.
there was one other aspect of this that i meant to touch on. to recap, i was passing a single Object to a coldfusion CFC method. in my little coldfusion brain, i thought of this as being not unlike a structure. so, i expected the method to receive a single argument much like a struct with multiple keys.
let's say my actionscript function looked like this:
- var args:Object = new Object();
- args.stateCode = "CA";
- args.zipCode = "94583";
- args.territory = 3;
- // call the remote object method
- ro_Customers.getFilteredCustomers(args);
i created an Object, populated it with 3 variables (keys), and passed it as an argument to the getFilteredCustomers() method in my remote object (CFC). originally, my CFC looked like this:
- <cffunction name="getFilteredCustomers" returntype="query" access="remote">
- <cfargument name="filterCriteria" type="struct" required="true" />
- ...
i assumed that my args Object would be able to be referenced as a structure in the CFC. it's a single variable with key/value pairs just like a struct. but when i tried to reference #arguments.filterCriteria.stateCode# i found that the variable didn't exist.
what actually happens is that the CFC treats each value in the Object as its own argument. think argumentCollection instead of struct.
the correct code for the CFC's arguments is:
- <cffunction name="getFilteredCustomers" returntype="query" access="remote">
- <cfargument name="stateCode" type="string" required="false" />
- <cfargument name="zipCode" type="string" required="false" />
- <cfargument name="territory" type="number" required="false" />
- ...
aside from explicitly declaring each value in the Object, i set the 'required' attribute to false because in this case, not all of the values may be present in the Object. a user might choose to search only on stateCode, or only on zipCode, etc.
flex: Objects are like structures. kinda.
april 18, 2008 at 2:52am
in ColdFusion, flex, flex for CF'ers
over the past few months i've been lucky enough to have the opportunity to start playing around with flex at work. overall it's been a pretty good experience. i think flex itself is a very cool technology, and flexbuilder absolutely ROCKS as an IDE. of course, there have been hurdles. some i was able to overcome pretty easily, and some left scars. i figured i'd post some of them here and hopefully save some other flex n00bs the hassle of figuring things out the hard way.
the application that i'm currently working on is fairly straightforward. let's call it a user manager. i present a couple of comboboxes that let the user filter by certain criteria (state, zipcode, etc) and populate a datagrid with the list of users that were returned.
i chose to pass these values in a single object. in coldfusion, this single object would be a structure. flex, or more appropriately, actionscript, has a comparable datatype, simply called Object. an Object would be created as follows:
- var args:Object = new Object();
- args.stateCode = "CA";
- args.zipCode = "94583";
- args.territory = 3;
fairly straightforward when compared to a coldfusion structure:
- <cfset args = structNew() />
- <cfset args.stateCode = "CA" />
- <cfset args.zipCode = "94583" />
- <cfset args.territory = 3 />