Flex/ColdFusion Mystery with a very simple answer
Yesterday I was working on a Flex project when I hit a brick wall. I had a very simple form. Flex was using remoting to send the form information to ColdFusion. ColdFusion was doing nothing with the data. It was just an empty method. However, every time I'd try to send the data I'd get an error.
Here is where things got weird. The first thing I tried was launching ServiceCapture so I could see the response from ColdFusion. However - when I would send the form data, ServiceCapture would actually hang. I had to force it down.
So then I went to my ColdFusion logs. Nothing was reported in the error log but an empty string. At this point I'm really confused. I go into my Application.cfc file's onError and added this:
<cfsavecontent variable="temp">
<cfdump var="#arguments#">
</cfsavecontent>
<cffile action="write" file="c:\foo.html" output="#temp#">
Now I get somewhere. When I look at the file, I see no message, no detail, but I do see a type for the error:
java.lang.StackOverflowError
What the heck? (Ok, I didn't say heck.) So now I start trying random crap. First I change the method names. Doesn't help. Finally I change my Flex code to send nothing to ColdFusion. And it works.
Um. Ok.
I restored my code and noticed something....
core.addAdminUser(username,password);
username and password were the form elements, not the values of the form elements. Somehow Flex thought this was ok. Can you really send a component over the wire? Flex could. And while it didn't die, it was enough to freak out ServiceCapture and ColdFusion. Changing my Flex to:
core.addAdminUser(username.text,password.text);
made everything kosher. Whew!
Coming later today - the second silly mistake I made...
Comments
It is like taking a chair out the front door and the rest of the house is dragged out the front door inside out. Careful with passing component instances through remoting. Flex will try do everything you ask.
Ted :)
// In a separate delegate class
public function addAdminUser( username:String, password:String )
{
core.addAdminUser( username, passwrod );
// possibly add responder here depending on what the
// rest of your code looks like
}
Then, all server communication goes through the delegate ensuring that the interface for client/server communication is the same on both ends.
public function addAdminUser( username:String, password:String ):Void
{ ... }
You 'should' strict type every function's return type, except the class constructors, which unlike ColdFusion, cannot have a return type.

