Receiving Flex Objects in Coldfusion, coldfusion component argument types

Flex Remoting with Coldfusion. Coldfusion Services and custom objects/components

I was getting frustrated when I COULD NOT receive a flex object as anything when a coldfusion service was receiving a remote call from flex. The coldfusion component had a method I was sending a call to. This method expected a struct arguement and then I was trying the argument type as on object. When I passed in the flex object to the remote method call in flex, when coldfusion received the argument it was breaking it apart and treating it as a messed up argument collection. Turns out you have to wrap a flex object in another object for coldfusion to receive it as a struct. Why the lack of documentation on this? I think flex remoting is really cool, but maybe it is a newer wave of development that just hasn’t been very popularized yet. I think that is changing.

In any case the following links really help with understanding how coldfusion and flex work together with remoting. Coldfusion components, like custom TO objects, can also be used across the wire, and vice-versa with flex objects. It is pretty slick, but you have to learn how to make coldfusion components and corresponding flex objects with properties that match, etc.

Nice article by Joel.

http://www.joelconnett.com/flexobjectstocoldfusion.html

I had originally found the following, which was helpful:

http://codingmurloc.wordpress.com/2007/05/15/passing-object-to-a-cfc-flex-or-cf-bug/

For custom component types, see also:

http://www.brucephillips.name/blog/index.cfm/2006/10/26/Exchaning-User-Defined-Objects-Between-ColdFusion-and-Flex

http://www.forta.com/blog/index.cfm/2006/2/1/The-Keys-To-Getting-CFC-ActionScript-AutoConversions-To-Work

Flex DataGrid rows. Does the selected item’s index in the dataprovider ArrayCollection change when the grid is re-sorted?

Yes.

For example, if I have 4 rows displaying user info, if the first row’s user has a name of ‘Kato’, the dataproviderUserArrayCollection[0].name = “Kato”.

What happens when I resort the rows by userNumber (or something) and Kato’s row is the third row? Is the the index of Kato’s Object in the array collection 0 or 2? It’s 2.

The array shifts to match the datagrid’s visual display (factuality, I’m sure the data model itself changes before the visual rendering is response to a click on a column title). So if Kato’s row moved from first place to third, so did his dataprovider array position. dataproviderUserArrayCollection[0].name = “Kato” shifted to dataproviderUserArrayCollection[2].name = “Kato”.

Dynamic argument list with coldfusion methods using argumentCollection

Check out the link, and learn how to use pass arguments to Coldfusion methods using the argumentCollection as your parameter. This is slick.

I was doing the following, concatenating my argument list to change with logic. I should have been using an argument struct instead of a clumsy string that was being evaluated like this:


<!--- This is a not so cool approach--->
<cfscript>
argsColl = "";
argsColl &= "username=Almonzo,";
argsColl &= "password="LauRa123";
authorized = securityCFC.getAuth(Evaluate(argsColl));
</cfscript>

The following was so much cooler, cut my code down, and made it so I didn’t have to figure out why the Evaluate function won’t evaluate strings with commas:)


<cfscript>
argsColl = structNew();
argsColl.username = "Almonzo";
argsColl.password = "LauRa123";
authorized = securityCFC.getAuth(argumentCollection = argsColl);
</cfscript>

Helpful link:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_28.html