In efforts to allow users to save their progress in my application, I've decided to allow them to save. In order to do this, I'd like to create an array with all the necessary information, and send that information to a coldfusion (.cfm) file and process the information from that page. Is it possible to send an array instead of a bunch of url variables? It is possible (and quite probable) that users would exceed the query string length of most browsers.
1 Answer
Yes, just use a post method instead of get. In ColdFusion this will come through the form scope instead of the url scope.
var request:URLRequest = new URLRequest(your-cf-page);
request.data = yourURLVariablesObject;
request.method = URLRequestMethod.POST //this is the important part
urlLoader.load(request);
Put your info in the URLVariables like you usually do...
yourURLVariablesObject.whatever
will become
#form.whatever#
on CF
Just a note... if you really want to make this work well, I'd consider using AMF and an RemoteObject. ColdFusion has the advantage of being able to directly talk to Flex via AMF.
var yourService:RemoteObject = new RemoteObject("ColdFusion");
yourService.source = "yourCFFiles.yourCFC";
Now you can call any method in yourCFC
3 Comments
sapptime
Jonathan - can you just pass the array directly as a property of your URLVariables? Just wondering - your answer is more specific (and probably better) than mine...
Jonathan Rowny
never tried it so not sure, but your urlvariables object can be large so you can put all the info you'd put in array into the urlvariables object. Regardless the best answer is still AMF if you're using ColdFusion because you can pass queries, arrays, even strongly typed objects back and forth with minimal effort.
sapptime
Yeah, I knew about the URLVariables stuff, I'm just not experienced with ColdFusion or AMF so wasn't sure there... I'll remove my answer - yours seems to be a better solution.