Re: [flexcoders] Calling ArrayStructures in CFCs from Flex
Absolumont! Tracy Spratt wrote: Message I’m sure Tarik will be happy to post it on CFLEX.net. Tracy From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of [EMAIL PROTECTED] Sent: Monday, August 15, 2005 4:09 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex Jeff, You were right! The problem was that I had to hard code my structure keys. For example: I've spent so long working out all the details of calling a facade cfc from Flex that I want to post the completed solution on some blog/site having to do with Flex. I really think others will benefit from a simple, straight-forward example. Do you have any suggestions on where to post this? Thanks again for all your help, Darius -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
RE: [flexcoders] Calling ArrayStructures in CFCs from Flex
Great, will definitely take a look, agreed, we certainly need some sort of reference…The dark art of Flex & CFC’s. Malcolm From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, 16 August 2005 6:13 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex Hi Malcolm, Thanks for your advice. Jeff's solutions worked well if you want to take a look. I'm going to try to post my completed solution on some site. Darius -Original Message- From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com]On Behalf Of Malcolm Sent: Wednesday, August 10, 2005 4:48 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex Hi Darius, I too went through the same pain (days & days of trying see what data types I could successfully return from a CFC). I'm still learning but in my somewhat limited experience I could find no way to return an array datatype, it just wouldn't do it no matter what I tried, same goes for structures. I have successfully returned the following datatypes: :String :Query :Boolean :Numeric (yet to try) :Date (yet to try) It's interesting to note that Flex (somehow) in the background actually converts a ColdFusion query to an array. (Search the group on how these can be accessed) At the moment I am mostly using queries to get data back. This has the unfortunate side effect of losing typing (everything in the query is a string), thus you may need cast some results etc to their correct type in Flex. Malcolm -Original Message- From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of coldfs Sent: Friday, 5 August 2005 7:29 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Calling ArrayStructures in CFCs from Flex Hi, Using Tom Link's blog (http://tomlink.net/blog/index.cfm? mode=entry&entry=B662BEF9-7E97-A3B0-E3FB286E23BDAA50) and other sources, I've been trying for days to translate queries to arrays of structures (and vice versa). Whatever I do, the cfc doesn't except my values from Flex as arrays. I know it's a chunk of code to review, but you'd help a sane man going slowly mad...:-) Many thanks, Darius --- index.mxml: --- http://www.macromedia.com/2003/mxml"> endpoint="http://gx270dev.net/flashservices/gateway" source="Model.mUtilities.mUpdate.qry_UpdateAuthorization" fault="mx.controls.Alert.show(event.fault.faultstring)" showBusyCursor="true"> result="doResult(event.result)"/> wordWrap="true" dataProvider="{RecordSetModel}"> width="200" headerText="Update Form" columnName="Function"/> width="320" headerText="Description" columnName="Description"/> -- fx_UpdateAuthorization.cfc -- ("component","qry_UpdateAuthorization")> returntype="array"> type="array" required="yes"> required="yes"> required="yes"> type="array" required="yes"> required="yes"> (obj.GetUpdateAuthorization (AuthorizedUserIdObject,CountyCodeObject,CaseFlagObject,CourtOrderAvai lableFlagObject,DsnObject))> - qry_UpdateAuthorization.cfc - returntype="query"> required="yes"> required="yes"> required="yes"> type="array" required="yes"> DATASOURCE="#Arguments.Dsn#"> TYPE="IN" VALUE="#Arguments.AuthorizedUserId#" CFSQLTYPE="CF_SQL_CHAR"> VALUE="#Arguments.CountyCode#" CFSQLTYPE="CF_SQL_CHAR"> VALUE="#Arguments.CaseFlag#" CFSQLTYPE="CF_SQL_CHAR"> DBVARNAME="CourtOrderAvailableFlag" TYPE="IN" VALUE="#Arguments.CourtOrderAvailableFlag#" CFSQLTYPE="CF_SQL_CHAR"> - Base.cfc - and easy debugging utility when testin
RE: [flexcoders] Calling ArrayStructures in CFCs from Flex
Hi Malcolm, Thanks for your advice. Jeff's solutions worked well if you want to take a look. I'm going to try to post my completed solution on some site. Darius -Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]On Behalf Of MalcolmSent: Wednesday, August 10, 2005 4:48 PMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from FlexHi Darius,I too went through the same pain (days & days of trying see what data typesI could successfully return from a CFC).I'm still learning but in my somewhat limited experience I could find no wayto return an array datatype, it just wouldn't do it no matter what I tried,same goes for structures. I have successfully returned the followingdatatypes::String:Query:Boolean:Numeric (yet to try):Date (yet to try)It's interesting to note that Flex (somehow) in the background actuallyconverts a ColdFusion query to an array. (Search the group on how these canbe accessed)At the moment I am mostly using queries to get data back. This has theunfortunate side effect of losing typing (everything in the query is astring), thus you may need cast some results etc to their correct type inFlex.Malcolm-Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] OnBehalf Of coldfsSent: Friday, 5 August 2005 7:29 AMTo: flexcoders@yahoogroups.comSubject: [flexcoders] Calling ArrayStructures in CFCs from FlexHi,Using Tom Link's blog (http://tomlink.net/blog/index.cfm?mode=entry&entry=B662BEF9-7E97-A3B0-E3FB286E23BDAA50) and other sources, I've been trying for days to translate queries to arrays of structures (and vice versa). Whatever I do, the cfc doesn't except my values from Flex as arrays. I know it's a chunk of code to review, but you'd help a sane man going slowly mad...:-)Many thanks,Darius---index.mxml:---http://www.macromedia.com/2003/mxml"> endpoint="http://gx270dev.net/flashservices/gateway" source="Model.mUtilities.mUpdate.qry_UpdateAuthorization" fault="mx.controls.Alert.show(event.fault.faultstring)" showBusyCursor="true"> result="doResult(event.result)"/> wordWrap="true" dataProvider="{RecordSetModel}"> width="200" headerText="Update Form" columnName="Function"/> width="320" headerText="Description" columnName="Description"/> --fx_UpdateAuthorization.cfc-- ("component","qry_UpdateAuthorization")> returntype="array"> type="array" required="yes"> required="yes"> required="yes"> type="array" required="yes"> required="yes"> (obj.GetUpdateAuthorization(AuthorizedUserIdObject,CountyCodeObject,CaseFlagObject,CourtOrderAvailableFlagObject,DsnObject))> -qry_UpdateAuthorization.cfc- returntype="query"> required="yes"> required="yes"> required="yes"> type="array" required="yes"> DATASOURCE="#Arguments.Dsn#"> TYPE="IN" VALUE="#Arguments.AuthorizedUserId#" CFSQLTYPE="CF_SQL_CHAR"> VALUE="#Arguments.CountyCode#" CFSQLTYPE="CF_SQL_CHAR"> VALUE="#Arguments.CaseFlag#" CFSQLTYPE="CF_SQL_CHAR"> DBVARNAME="CourtOrderAvailableFlag" TYPE="IN" VALUE="#Arguments.CourtOrderAvailableFlag#" CFSQLTYPE="CF_SQL_CHAR"> -Base.cfc- required="yes"> addnewline="yes" output="#varToOutput#"> /** * Converts a query object into an array of structures. * * @param query The query to be transformed * @return This function returns a structure. * @author Nathan Dintenfass ([EMAIL PROTECTED]) * @version 1, September 27, 2001 */ function QueryToArrayOfStructures(theQuery){ var theArray = arraynew(1); var cols = ListtoArray(theQuery.columnlist); var row = 1; var thisRow = ""; var col = 1; for(row = 1; row LTE theQuery.recordcount; row = row + 1){ thisRow = structnew();
Re: [flexcoders] Calling ArrayStructures in CFCs from Flex
this works the best, returns a true array of objects to Flex. Define DataVO in a separate CFC. On 8/12/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Thanks, Jeff. That helps... > > I'm still stuck on how to handle the return recordset from the cfc. If case > sensitivity doesn't matter, how do you recommend dynamically getting all the > data into the structure? > > > > > > > > > > -Original Message- > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] > Behalf Of Battershall, Jeff > Sent: Friday, August 12, 2005 6:38 AM > To: flexcoders@yahoogroups.com > Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex > > > Darius, > > What you want is an array of structures (what Flex wants), not a structure > of arrays (what a CF Query is). By using queryname.columnList, you get the > keys you want to dynamically populate each structure, but unfortunately, > case sensitivity of column names isn't preserved - so you may end up hard > coding each structure key if case sensitivity of your struct keys matters to > your application. Also, your cfset var will have to be placed at the top of > the function body, just after your CFARGUMENT tags. > > Jeff > > > -Original Message- > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of [EMAIL PROTECTED] > Sent: Thursday, August 11, 2005 5:57 PM > To: flexcoders@yahoogroups.com > Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex > > > Jeff, > > Great example! It almost works for me except the cfc I call from Flex is a > facade to my cfc query. The cfc query returns a variable that needs to be > converted to an array or whatever before being put into a structure. Do you > have any ideas how to do this? Many thanks, Darius > > > > > returnType="Array"> > > > > > > >"Model.mUtilities.mUpdate.qry_UpdateAuthorization"> > > >returnvariable="qGetUpdateAuthorization"> > > > > value="#CourtOrderAvailableFlag#"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Original Message- > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Battershall, Jeff > Sent: Thursday, August 11, 2005 8:38 AM > To: flexcoders@yahoogroups.com > Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex > > I'm jonny-come-lately to this thread, but I send and return arrays and > structures to/from CFCs all the time. I've abandoned passing back > CFQueries as such but convert them to an array of structures first as > that is what Flex UIComponents seem to like. > > Example code: > > access="public"> > > > > > procedure="sp_GetIndustryCategories" > datasource="#getDataSource()#"> > > > > > > > > > > > > > > > > If you were dealing with a dynamic list of columns the code could be > altered as such: > > > > > > > > > > > > > > > Produced in this fashion, Flex WILL accept this result as an array of > structures. I'm mystified at the problem you're experiencing. > > Jeff > > -Original Message- > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Malcolm > Sent: Wednesday, August 10, 2005 7:48 PM > To: flexcoders@yahoogroups.com > Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex > > > Hi Darius, > > I too went through the same pain (days & days of trying see what data > types I could successfully return from a CFC). > > I'm still learning but in my somewhat limited experience I could find no > way to return an array datatype, it just wouldn't do it no matter what I > tried, same goes for structures. I have successfully returned the > following > datatypes: > &
RE: [flexcoders] Calling ArrayStructures in CFCs from Flex
Title: Message Thanks, Jeff. That helps... I'm still stuck on how to handle the return recordset from the cfc. If case sensitivity doesn't matter, how do you recommend dynamically getting all the data into the structure? -Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]On Behalf Of Battershall, JeffSent: Friday, August 12, 2005 6:38 AMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex Darius, What you want is an array of structures (what Flex wants), not a structure of arrays (what a CF Query is). By using queryname.columnList, you get the keys you want to dynamically populate each structure, but unfortunately, case sensitivity of column names isn't preserved - so you may end up hard coding each structure key if case sensitivity of your struct keys matters to your application. Also, your cfset var will have to be placed at the top of the function body, just after your CFARGUMENT tags. Jeff -Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]Sent: Thursday, August 11, 2005 5:57 PMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex Jeff, Great example! It almost works for me except the cfc I call from Flex is a facade to my cfc query. The cfc query returns a variable that needs to be converted to an array or whatever before being put into a structure. Do you have any ideas how to do this? Many thanks, Darius -Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Battershall, JeffSent: Thursday, August 11, 2005 8:38 AMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from FlexI'm jonny-come-lately to this thread, but I send and return arrays andstructures to/from CFCs all the time. I've abandoned passing backCFQueries as such but convert them to an array of structures first asthat is what Flex UIComponents seem to like. Example code:access="public"> datasource="#getDataSource()#"> If you were dealing with a dynamic list of columns the code could bealtered as such: Produced in this fashion, Flex WILL accept this result as an array ofstructures. I'm mystified at the problem you're experiencing. Jeff-Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] OnBehalf Of MalcolmSent: Wednesday, August 10, 2005 7:48 PMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from FlexHi Darius,I too went through the same pain (days & days of trying see what datatypes I could successfully return from a CFC).I'm still learning but in my somewhat limited experience I could find noway to return an array datatype, it just wouldn't do it no matter what Itried, same goes for structures. I have successfully returned thefollowingdatatypes::String:Query:Boolean:Numeric (yet to try):Date (yet to try)It's interesting to note that Flex (somehow) in the background actuallyconverts a ColdFusion query to an array. (Search the group on how thesecan be accessed)At the moment I am mostly using queries to get data back. This has theunfortunate side effect of losing typing (everything in the query is astring), thus you may need cast some results etc to their correct typein Flex.Malcolm-Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] OnBehalf Of coldfsSent: Friday, 5 August 2005 7:29 AMTo: flexcoders@yahoogroups.comSubject: [flexcoders] Calling ArrayStructures in CFCs from FlexHi,Using Tom Link's blog (http://tomlin
RE: [flexcoders] Calling ArrayStructures in CFCs from Flex
Title: Message Darius, What you want is an array of structures (what Flex wants), not a structure of arrays (what a CF Query is). By using queryname.columnList, you get the keys you want to dynamically populate each structure, but unfortunately, case sensitivity of column names isn't preserved - so you may end up hard coding each structure key if case sensitivity of your struct keys matters to your application. Also, your cfset var will have to be placed at the top of the function body, just after your CFARGUMENT tags. Jeff -Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]Sent: Thursday, August 11, 2005 5:57 PMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex Jeff, Great example! It almost works for me except the cfc I call from Flex is a facade to my cfc query. The cfc query returns a variable that needs to be converted to an array or whatever before being put into a structure. Do you have any ideas how to do this? Many thanks, Darius -Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Battershall, JeffSent: Thursday, August 11, 2005 8:38 AMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from FlexI'm jonny-come-lately to this thread, but I send and return arrays andstructures to/from CFCs all the time. I've abandoned passing backCFQueries as such but convert them to an array of structures first asthat is what Flex UIComponents seem to like. Example code:access="public"> datasource="#getDataSource()#"> If you were dealing with a dynamic list of columns the code could bealtered as such: Produced in this fashion, Flex WILL accept this result as an array ofstructures. I'm mystified at the problem you're experiencing. Jeff-Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] OnBehalf Of MalcolmSent: Wednesday, August 10, 2005 7:48 PMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from FlexHi Darius,I too went through the same pain (days & days of trying see what datatypes I could successfully return from a CFC).I'm still learning but in my somewhat limited experience I could find noway to return an array datatype, it just wouldn't do it no matter what Itried, same goes for structures. I have successfully returned thefollowingdatatypes::String:Query:Boolean:Numeric (yet to try):Date (yet to try)It's interesting to note that Flex (somehow) in the background actuallyconverts a ColdFusion query to an array. (Search the group on how thesecan be accessed)At the moment I am mostly using queries to get data back. This has theunfortunate side effect of losing typing (everything in the query is astring), thus you may need cast some results etc to their correct typein Flex.Malcolm-Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] OnBehalf Of coldfsSent: Friday, 5 August 2005 7:29 AMTo: flexcoders@yahoogroups.comSubject: [flexcoders] Calling ArrayStructures in CFCs from FlexHi,Using Tom Link's blog (http://tomlink.net/blog/index.cfm?mode=entry&entry=B662BEF9-7E97-A3B0-E3FB286E23BDAA50) and other sources, I've been trying for days to translate queries to arrays of structures (and vice versa). Whatever I do, the cfc doesn't except my values from Flex as arrays. I know it's a chunk of code to review, but you'd help a sane man going slowly mad...:-)Many thanks,Darius---index.mxml:---http://www.macromedia.com/2003/mxml"> endpoint="http://gx270dev.net/flashservices/gateway" source="Model.mUtilities.mUpdate.qry_UpdateAuthorization" fault="mx.controls.Alert.show(event.fault.faultstring)" showBusyCursor="true&q
RE: [flexcoders] Calling ArrayStructures in CFCs from Flex
Title: Message Jeff, Great example! It almost works for me except the cfc I call from Flex is a facade to my cfc query. The cfc query returns a variable that needs to be converted to an array or whatever before being put into a structure. Do you have any ideas how to do this? Many thanks, Darius -Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Battershall, JeffSent: Thursday, August 11, 2005 8:38 AMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from FlexI'm jonny-come-lately to this thread, but I send and return arrays andstructures to/from CFCs all the time. I've abandoned passing backCFQueries as such but convert them to an array of structures first asthat is what Flex UIComponents seem to like. Example code:access="public"> datasource="#getDataSource()#"> If you were dealing with a dynamic list of columns the code could bealtered as such: Produced in this fashion, Flex WILL accept this result as an array ofstructures. I'm mystified at the problem you're experiencing. Jeff-Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] OnBehalf Of MalcolmSent: Wednesday, August 10, 2005 7:48 PMTo: flexcoders@yahoogroups.comSubject: RE: [flexcoders] Calling ArrayStructures in CFCs from FlexHi Darius,I too went through the same pain (days & days of trying see what datatypes I could successfully return from a CFC).I'm still learning but in my somewhat limited experience I could find noway to return an array datatype, it just wouldn't do it no matter what Itried, same goes for structures. I have successfully returned thefollowingdatatypes::String:Query:Boolean:Numeric (yet to try):Date (yet to try)It's interesting to note that Flex (somehow) in the background actuallyconverts a ColdFusion query to an array. (Search the group on how thesecan be accessed)At the moment I am mostly using queries to get data back. This has theunfortunate side effect of losing typing (everything in the query is astring), thus you may need cast some results etc to their correct typein Flex.Malcolm-Original Message-From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] OnBehalf Of coldfsSent: Friday, 5 August 2005 7:29 AMTo: flexcoders@yahoogroups.comSubject: [flexcoders] Calling ArrayStructures in CFCs from FlexHi,Using Tom Link's blog (http://tomlink.net/blog/index.cfm?mode=entry&entry=B662BEF9-7E97-A3B0-E3FB286E23BDAA50) and other sources, I've been trying for days to translate queries to arrays of structures (and vice versa). Whatever I do, the cfc doesn't except my values from Flex as arrays. I know it's a chunk of code to review, but you'd help a sane man going slowly mad...:-)Many thanks,Darius---index.mxml:---http://www.macromedia.com/2003/mxml"> endpoint="http://gx270dev.net/flashservices/gateway" source="Model.mUtilities.mUpdate.qry_UpdateAuthorization" fault="mx.controls.Alert.show(event.fault.faultstring)" showBusyCursor="true"> result="doResult(event.result)"/> wordWrap="true" dataProvider="{RecordSetModel}"> width="200" headerText="Update Form" columnName="Function"/> width="320" headerText="Description" columnName="Description"/> --fx_UpdateAuthorization.cfc-- ("component","qry_UpdateAuthorization")> returntype="array"> type="array" required="yes"> required="yes"> required="yes"> type="array" required="yes"> required="yes"> (obj.GetUpdateAuthorization(AuthorizedUserIdObject,CountyCodeObject,CaseFlagObject,CourtOrderAvailableFlagObject,DsnObject))> -qry_UpdateAuthorization.cfc- returntype="query"> required="yes">
RE: [flexcoders] Calling ArrayStructures in CFCs from Flex
I'm jonny-come-lately to this thread, but I send and return arrays and structures to/from CFCs all the time. I've abandoned passing back CFQueries as such but convert them to an array of structures first as that is what Flex UIComponents seem to like. Example code: If you were dealing with a dynamic list of columns the code could be altered as such: Produced in this fashion, Flex WILL accept this result as an array of structures. I'm mystified at the problem you're experiencing. Jeff -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Malcolm Sent: Wednesday, August 10, 2005 7:48 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Calling ArrayStructures in CFCs from Flex Hi Darius, I too went through the same pain (days & days of trying see what data types I could successfully return from a CFC). I'm still learning but in my somewhat limited experience I could find no way to return an array datatype, it just wouldn't do it no matter what I tried, same goes for structures. I have successfully returned the following datatypes: :String :Query :Boolean :Numeric (yet to try) :Date (yet to try) It's interesting to note that Flex (somehow) in the background actually converts a ColdFusion query to an array. (Search the group on how these can be accessed) At the moment I am mostly using queries to get data back. This has the unfortunate side effect of losing typing (everything in the query is a string), thus you may need cast some results etc to their correct type in Flex. Malcolm -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of coldfs Sent: Friday, 5 August 2005 7:29 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Calling ArrayStructures in CFCs from Flex Hi, Using Tom Link's blog (http://tomlink.net/blog/index.cfm? mode=entry&entry=B662BEF9-7E97-A3B0-E3FB286E23BDAA50) and other sources, I've been trying for days to translate queries to arrays of structures (and vice versa). Whatever I do, the cfc doesn't except my values from Flex as arrays. I know it's a chunk of code to review, but you'd help a sane man going slowly mad...:-) Many thanks, Darius --- index.mxml: --- http://www.macromedia.com/2003/mxml";> http://gx270dev.net/flashservices/gateway"; source="Model.mUtilities.mUpdate.qry_UpdateAuthorization" fault="mx.controls.Alert.show(event.fault.faultstring)" showBusyCursor="true"> -- fx_UpdateAuthorization.cfc -- - qry_UpdateAuthorization.cfc - - Base.cfc - /** * Converts a query object into an array of structures. * * @param query The query to be transformed * @return This function returns a structure. * @author Nathan Dintenfass ([EMAIL PROTECTED]) * @version 1, September 27, 2001 */ function QueryToArrayOfStructures(theQuery){ var theArray = arraynew(1); var cols = ListtoArray(theQuery.columnlist); var row = 1; var thisRow = ""; var col = 1; for(row = 1; row LTE theQuery.recordcount; row = row + 1){ thisRow = structnew(); f
RE: [flexcoders] Calling ArrayStructures in CFCs from Flex
Hi Darius, I too went through the same pain (days & days of trying see what data types I could successfully return from a CFC). I'm still learning but in my somewhat limited experience I could find no way to return an array datatype, it just wouldn't do it no matter what I tried, same goes for structures. I have successfully returned the following datatypes: :String :Query :Boolean :Numeric (yet to try) :Date (yet to try) It's interesting to note that Flex (somehow) in the background actually converts a ColdFusion query to an array. (Search the group on how these can be accessed) At the moment I am mostly using queries to get data back. This has the unfortunate side effect of losing typing (everything in the query is a string), thus you may need cast some results etc to their correct type in Flex. Malcolm -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of coldfs Sent: Friday, 5 August 2005 7:29 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Calling ArrayStructures in CFCs from Flex Hi, Using Tom Link's blog (http://tomlink.net/blog/index.cfm? mode=entry&entry=B662BEF9-7E97-A3B0-E3FB286E23BDAA50) and other sources, I've been trying for days to translate queries to arrays of structures (and vice versa). Whatever I do, the cfc doesn't except my values from Flex as arrays. I know it's a chunk of code to review, but you'd help a sane man going slowly mad...:-) Many thanks, Darius --- index.mxml: --- http://www.macromedia.com/2003/mxml";> http://gx270dev.net/flashservices/gateway"; source="Model.mUtilities.mUpdate.qry_UpdateAuthorization" fault="mx.controls.Alert.show(event.fault.faultstring)" showBusyCursor="true"> -- fx_UpdateAuthorization.cfc -- - qry_UpdateAuthorization.cfc - - Base.cfc - /** * Converts a query object into an array of structures. * * @param query The query to be transformed * @return This function returns a structure. * @author Nathan Dintenfass ([EMAIL PROTECTED]) * @version 1, September 27, 2001 */ function QueryToArrayOfStructures(theQuery){ var theArray = arraynew(1); var cols = ListtoArray(theQuery.columnlist); var row = 1; var thisRow = ""; var col = 1; for(row = 1; row LTE theQuery.recordcount; row = row + 1){ thisRow = structnew(); for(col = 1; col LTE arraylen(cols); col = col + 1){ thisRow[cols[col]] = theQuery[cols [col]][row]; } arrayAppend(theArray,duplicate(thisRow)); } return(theArray); } /** * Converts an array of structures to a CF Query Object. * 6-19-02: Minor revision by Rob Brooks-Bilson ([EMAIL PROTECTED]) * * Update to handle empty array passed in. Mod by Nathan Dintenfass. Also no longer using list func. * * @param Array The array of structures to be converted to a query object. Assumes each array element contains structure with same (Required) * @return Returns a query object. * @author David Crawford ([EMAIL PROTECTED]) * @version 2, March 19, 2003 */ function arrayOfStructuresToQuery(theArray){ var colNames = ""; var theQuery = queryNew(""); var i=0; var j=0; //if there's nothing in the array, return the empty query if(NOT arrayLen(theArray)) return theQuery; //get the column names into an array = colNames = struc