House of Fusion
Home of the ColdFusion Community
Hostmysite Dedicated Hosting

Search flex

July 25, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     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     

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition

For ColdFusion hosting try HostMySite.com.
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  Adobe Flex 2

How do you handle an arraycollection in ColdFusion ?

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
jason robinson
05/14/2008 05:51 PM

Hi there, I have a Flex app where I pass an arraycollection to my cfc. I've been trying to set the argument type as a 'struct' but I get an error stating that my arraycollection is not of type struct. I've also tries setting it as an array. No luck. Any thoughts? Thanks. Novian Code: <cffunction name="saveQuiz" access="remote" returntype="boolean" hint="Saves new quiz to quiz_questions.">     <cfargument name="quizQuestion" type="string" required="yes">     <cfargument name="quizAnswer" type="string" required="yes">     <cfargument name="optionsAC" type="struct" required="yes">     <cfset var qRead="">     <cfquery name="savedQuizQuestion" datasource="my_db" result="savedQuizID"> INSERT into quiz_questions (quizQuestion, quizAnswer) VALUES ('#ARGUMENTS.quizQuestion#', '#ARGUMENTS.quizAnswer#')   </cfquery>     <cfloop from="1" to="#ArrayLen(optionsAC.optionsArray)#" index="i">     <cfquery name="savedQuizOptions" datasource="my_db"> INSERT into quiz_options (quizID, optionName, correct) VALUES ('#savedQuizID.GENERATED_KEY#', '#optionsAC.optionsArray[i].label#', '#optionsAC.optionsArray[i].data#') </cfquery> </cfloop>     <cfreturn true>     </cffunction>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jennifer Larkin
05/14/2008 06:00 PM

You're going to hit yourself in the head when I say this, but have you tried type="array"? On Wed, May 14, 2008 at 2:50 PM, jas ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jennifer Larkin
05/14/2008 06:00 PM

Oh nevermind, you said you did that. You could just leave the type off and pray. On Wed, May 14, 2008 at 2:59 PM, Jennifer Larkin <jlarkin@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Charlie Griefer
05/14/2008 06:15 PM

If you're not a praying man, don't send the ArrayCollection. ArrayCollection is really just a wrapper for an array that adds some extra functionality like getItemAt().  Pass in the underlying array, which would be optionsAC.source. then you'll be able to type your cfargument to an array. On Wed, May 14, 2008 at 2:59 PM, Jennifer Larkin <jlarkin@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
jason robinson
05/14/2008 06:34 PM

----- Excess quoted text cut - see Original Post for more ----- Thanks for the quick reply, guys. Charlie: You're right, I'm not a praying man AND your advice worked! :) Thanks so much. I've included the amended code in case anyone is interested. Code: <cffunction name="saveQuiz" access="remote" returntype="boolean" hint="Saves new quiz to quiz_questions.">     <cfargument name="quizQuestion" type="string" required="yes">     <cfargument name="quizAnswer" type="string" required="yes">     <cfargument name="optionsAC" type="array" required="yes">     <cfset var qRead="">     <cfquery name="savedQuizQuestion" datasource="my_db" result="savedQuizID"> INSERT into quiz_questions (quizQuestion, quizAnswer) VALUES ('#ARGUMENTS.quizQuestion#', '#ARGUMENTS.quizAnswer#')   </cfquery>     <cfloop from="1" to="#ArrayLen(optionsAC)#" index="i">     <cfquery name="savedQuizOptions" datasource="my_db"> INSERT into quiz_options (quizID, optionName, correct) VALUES ('#savedQuizID.GENERATED_KEY#', '#optionsAC[i].label#', '#optionsAC[i].data#') </cfquery> </cfloop>     <cfreturn true>     </cffunction>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Hastings
05/14/2008 07:00 PM

jas ----- Excess quoted text cut - see Original Post for more ----- just to nit pick, your forgot to var scope your cfloop index "i" & the names of your queries (savedQuizQuestion & savedQuizOptions). and what you do var scope (qRead) doesn't seem to get used.

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
05/14/2008 06:37 PM

> I have a Flex app where I pass an arraycollection to my cfc. > I've been trying to set the argument type as a 'struct' but I > get an error stating that my arraycollection is not of type > struct. I've also tries setting it as an array. No luck. > Any thoughts? I don't think ArrayCollection is supported by Flash Remoting. The specific datatypes supported are listed here: http://livedocs.adobe.com/coldfusion/8/htmldocs/usingSalsaN_4.html Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Training: Adobe/Google/Paperthin Certified Partners http://training.figleaf.com/ WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers! http://www.webmaniacsconference.com/


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists