Sunday, May 11, 2008    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< May 2008 >>
S M T W T F S
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
             

Search

Categories
 • Adobe (61) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (6) [RSS]
 • AIR (95) [RSS]
 • Appearances (103) [RSS]
 • Books (65) [RSS]
 • CFEclipse (14) [RSS]
 • ColdFusion (1078) [RSS]
 • Flash (88) [RSS]
 • Flex (316) [RSS]
 • Jobs (81) [RSS]
 • JRun (12) [RSS]
 • Labs (26) [RSS]
 • LiveCycle (11) [RSS]
 • MAX (141) [RSS]
 • Regular Expressions (12) [RSS]
 • SQL (36) [RSS]
 • Stuff (492) [RSS]
 • Tips (CF Studio) (80) [RSS]
 • Tips (CF) (795) [RSS]
 • Tips (Dreamweaver) (91) [RSS]
 • Tips (Flex Builder) (2) [RSS]
 • Using CF (131) [RSS]
 • Wireless (96) [RSS]

Other BLOGs
 • Ray Camden
 • Tim Buntel
 • Sean Corfield
 • John Dowdell
 • Steven Erat
 • Brandon Purcell
 • Charlie Arehart
 • Full As A Goog

RSS Feeds
 • Feed
 • Subscribe

Join my mailing list and find out about new books and other topics of interest.

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.

Viewing By Entry / Main
May 7, 2008

Preserving ColdFusion Structure Member Case In Flex

ColdFusion is case-insensitive, and Flex MXML and ActionScript are very case-sensitive. For consistency's sake, when ColdFusion variables are sent from ColdFusion to the Flash Player via Flash Remoting, names are converted to uppercase (that's the default behavior, and it can be changed if needed). So, a structure member named FirstName will be named FIRSTNAME when it arrives on the Flash Player (and referring to it as FirstName in MXML or ActionScript won't work).

But, you actually can force case to be maintained in structures, depending on how structure members are defined. Look at these two examples. The first won't preserve case:

<cfset user=StructNew()>
<cfset user.FirstName="Ben">
<cfset user.LastName="Forta">

In this example, if the structure were returned to the Flash Player, the members would be named FIRSTNAME and LASTNAME.

Here's another example, one that will indeed preserve case:

<cfset user=StructNew()>
<cfset user["FirstName"]="Ben">
<cfset user["LastName"]="Forta">

This example accomplishes the exact same result as the previous example, in that it creates a structure and defines two members. But in this example, structure member names will be preserved, and they would indeed be named FirstName and LastName when they arrive in the Flash Player.

TrackBacks
There are no trackbacks for this entry.

No trackback URL. Trackbacks are only allowed via interactive form.

Comments
Ben said: "For consistency's sake, when ColdFusion variables are sent from ColdFusion to the Flash Player via Flash Remoting, names are converted to uppercase (that's the default behavior, and it can be changed if needed)."

The solution posted here is the way to change what you name "default behavior", or is there a way to do it directly on CF's Flash Remoting config?

Thank you Ben!
# Posted By Vicente Junior | 5/7/08 1:23 PM
I second Vicente's question. Is there any way to do this other than changing the syntax?

Mike.
# Posted By Mike Kelp | 5/7/08 2:08 PM
Vicente,

The default is all uppercase, but you can change to that to force to all lowercase by setting the <force-cfc-lowercase> <force-query-lowercase> and <force-query-lowercase> (in the remoting-config file) properties to true. However, if you do so, the names will be converted to lowercase, and they'll still not be in the mixed case they were originally in the example I posted.

--- Ben
# Posted By Ben Forta | 5/7/08 2:19 PM
Thank you Ben!
So, as I'd checked on WEB-INF\Flex\data-management-config.xml and WEB-INF\Flex\remoting-config.xml, there's no way to make CF keep mixed case as default.
# Posted By Vicente Junior | 5/7/08 3:30 PM
Correct, the options force all uppercase or all lowercase.

--- Ben
# Posted By Ben Forta | 5/7/08 9:53 PM
Is there an easy way to make this work for query results sent to Flash Player?
# Posted By Eric Belair | 5/8/08 9:16 AM
@Eric
No, I don't think so.
You could use AOP (i.e. ColdSpring) to convert the query into an array of VO fairly easily though.

Using VO on both the Flex and ColdSpring ends is the other way to preserve case in properties, just make sure the CFC alias="" AND as [RemoteClass] match.
The ColdFusion extensions for Eclipse can make an AS VO from a CFC and vica versa automagically.
# Posted By Tom Chiverton | 5/8/08 11:19 AM
If you are using MySQL Ver 5.0 JDBC drivers mysql-connector-java-5.1.6-bin.jar
the case is being preserved.

SELECT FirstName, LastName from Users = "FirstName" & "LastName"

SELECT FIRSTNAME, LASTNAME from Users = "FIRSTNAME" & "LASTNAME"


Tom, thanks for the alias and [RemoteClass] match... will keep that in mind.
-Hem
# Posted By Hem Talreja | 5/8/08 12:11 PM
Thanks Tom. I'm returning query Objects from CFC to my Flex application, and then creating Class Objects with properties for each record. I don't like having the properties in ALL CAPS, because it doesn't coincide with my Naming Conventions. Guess it's just something I'll have to deal with, or write another script to convert the case.
# Posted By Eric Belair | 5/8/08 2:55 PM

  © Copyright 1997-2008 Ben Forta, All Rights Reserved