Kyle Hayes

Tech, Musings, Life

ColdFusion Struct to Flex Untyped Object Gotcha

| Comments

Flex and ColdFusion work great together…most of the time. Between the two application frameworks data transformation works really well. For instance, when you pass a ColdFusion query object to Flex, Flex sees it as an ArrayCollection. If you pass an Flex ArrayCollection, ColdFusion automatically interprets it as a ColdFusion query object.

This works great in almost all cases. Something to watch out for when sending ColdFusion structs to Flex is that if you use the “dot-notation” of defining the keys, then in Flex when referencing the keys, the key name must in all caps.

// ColdFusion myStruct.firstName = "Kyle"; // Flex trace(myCFStruct.FIRSTNAME);

On the other hand, if you use bracket notation the case follows that of what is inside the quotations.

// ColdFusion myStruct["FirstName"] = "Kyle"; // Flex trace(myCFStruct.FirstName);

Comments