not sure if this will help Darius, but here is how i did basically 
the same thing...hth

***** CFC code *****

<!--- The coldfusion component or 'cfc' is defined within the scope 
of the <cfcomponent> tag --->
<cfcomponent hint="This is the empObj component which provides query 
functionality to Flex component - stlUserIDForm.">

<cffunction name="getuserinfo" access="remote" returntype="struct" 
output="true" hint="query the database to get user info"> 

<cfargument name="UserID" type="string" default="">

<cfset DIR_USER = " xxxxxxx">
   <cfset DIR_PASS = "xxxxxx">
   <cfset DIR_SRVR = "xxxxx.com">
 <!--- Query the Database to get right UserInfo --->
      <cfldap Name="getInfo"
              SERVER="#DIR_SRVR#"
              USERNAME="#DIR_USER#"
              PASSWORD="#DIR_PASS#"
              ACTION="Query"
              ATTRIBUTES="Name, givenname, sn, initials, mail, 
Number, 
                                                  ID, PrefUID, 
telephoneNumber, MailCode, Building, 
departmentNumber,ExternalCompany, boeingSponsor, manager"
               START="ou=people, o=xxxxx, c=us"
               FILTER="ID=#UserID#"
               SCOPE="OneLevel">

<!--- make the different strings so we get just the mgr & sponsor 
bemsid's --->
<cfif #Len(getInfo.manager)# GT 0>
        <cfset #getInfo.ExternalCompany# = "">
        <cfset tempmgr = #SpanExcluding(#getInfo.manager#, ",")#>
<cfoutput>tempmgr is: #tempmgr#<br></cfoutput>
        <cfset tempmgr2 = #RemoveChars(#tempmgr#, 1, 3)#>
   <cfset DIR_USER = " xxxxxx">
   <cfset DIR_PASS = "xxxxxxxxxx">
   <cfset DIR_SRVR = "xxxxxxxxx.com">
 <!--- Query the Database to get right Manager Info --->
      <cfldap Name="getmgrInfo"
              SERVER="#DIR_SRVR#"
              USERNAME="#DIR_USER#"
              PASSWORD="#DIR_PASS#"
              ACTION="Query"
              ATTRIBUTES="DisplayName, givenname, sn, initials, 
mail, ID, telephoneNumber"
               START="ou=people, o=boeing, c=us"
               FILTER="ID=#tempmgr2#"
               SCOPE="OneLevel">
        <cfset tempmgr3 = #getmgrInfo.DisplayName#>
<cfelse>
        <cfset #tempmgr3# = " ">
        <cfset #getmgrInfo.telephoneNumber# = "">
        <cfset #getmgrInfo.ID# = "">
</cfif>
<!--- if they are non-US do this one --->
<cfif #Len(getInfo.Sponsor)# GT 0>
        <cfset tempsponsor = #SpanExcluding(getInfo.Sponsor, ",")#>
        <cfset tempsponsor2 = #RemoveChars(#tempsponsor#, 1, 3)#>

        <cfset DIR_USER = " xxxxxx">
    <cfset DIR_PASS = "xxxxxxxx">
    <cfset DIR_SRVR = "xxxxxxxxxx.com">
 <!--- Query the Database to get right UserInfo --->
      <cfldap Name="getsponsorInfo"
              SERVER="#DIR_SRVR#"
              USERNAME="#DIR_USER#"
              PASSWORD="#DIR_PASS#"
              ACTION="Query"
              ATTRIBUTES="DisplayName, givenname, sn, initials, 
mail,departmentNumber, ID, telephoneNumber"
               START="ou=people, o=xxxxx, c=us"
               FILTER="ID=#tempsponsor2#"
               SCOPE="OneLevel">
<cfelse>
        <cfset #tempsponsor2# = "">
        <cfset #getsponsorInfo.DisplayName# = "">
        <cfset #getsponsorInfo.mail# = "">
        <cfset #getsponsorInfo.departmentNumber# = "">
        <cfset #getsponsorInfo.telephoneNumber# = "">
        
</cfif> 

<cfscript>
   employee = StructNew();
   StructInsert(employee, "name", getInfo.DisplayName);
   StructInsert(employee, "firstname", getInfo.givenname);
   StructInsert(employee, "lastname", getInfo.sn);
   StructInsert(employee, "initials", getInfo.initials);
   StructInsert(employee, "email", getInfo.mail);
   StructInsert(employee, "clocknumber", getInfo.Number);
   StructInsert(employee, "bemsid", getInfo.ID);
   StructInsert(employee, "prefuid", getInfo.PrefUID);
   StructInsert(employee, "phone", getInfo.telephoneNumber);   
   StructInsert(employee, "mailcode", getInfo.MailCode);   
   StructInsert(employee, "bldg", getInfo.Building);
   StructInsert(employee, "department", getInfo.departmentNumber);   
   StructInsert(employee, "extcompany", getInfo.ExternalCompany);
   StructInsert(employee, "sponsorsID", #tempsponsor2#);      
   StructInsert(employee, "manager", #tempmgr3#);      
   StructInsert(employee, "managersPhone", 
getmgrInfo.telephoneNumber);         
   StructInsert(employee, "managersID", getmgrInfo.ID);      
   StructInsert(employee, "sponsorsName", 
getsponsorInfo.DisplayName);
   StructInsert(employee, "sponsorsEmail", getsponsorInfo.mail);
   StructInsert(employee, "sponsorsDept", 
getsponsorInfo.departmentNumber);
   StructInsert(employee, "sponsorsPhone", 
getsponsorInfo.telephoneNumber);

 </cfscript>
       <cfreturn employee>

</cffunction>


</cfcomponent>

--- In [email protected], <[EMAIL PROTECTED]> wrote:
> 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
>  
> <cfcomponent>
>  
> <!--- Data coming in from Flex --->
>  <cffunction name="invUpdateAuthorization" access="remote"
> returnType="Array">
>   <cfargument name="Input" required="true" type="Array"> 
>   <cfset AuthorizedUserId = input[1] >
>   <cfset CCode = input[2] >
>   <cfset CFlag = input[3] >
>   <cfset COAvailableFlag = input[4] >
>   <cfset Dsn = input[5] >
>   <cfset ComponentPath =
> "Model.mUtilities.mUpdate.qry_UpdateAuthorization">
>   
> <!--- This is the call to the query that returns the recordset
> qGetUpdateAuthorization --->
>   <cfinvoke component="#ComponentPath#" 
method="GetUpdateAuthorization"
> returnvariable="qGetUpdateAuthorization">
>    <cfinvokeargument name="AuthorizedUserId" 
value="#AuthorizedUserId#">
>    <cfinvokeargument name="CountyCode" value="#CountyCode#">
>    <cfinvokeargument name="CaseFlag" value="#CaseFlag#">
>    <cfinvokeargument name="CourtOrderAvailableFlag"
> value="#CourtOrderAvailableFlag#">
>    <cfinvokeargument name="Dsn" value="#Dsn#">
>   </cfinvoke>
>  
> <!--- How do I get this component recordset into your Structure of
> arrays? --->
>   
>   <cfset var arrResult = ArrayNew(1)/>
>         <cfset var stItem = StructNew()/> 
>   
>    
>         <cfoutput query="qGetUpdateAuthorization">
>             <cfset stItem = StructNew()/>
>             <cfset stItem["label"] = label/>
>             <cfset stItem["data"] = data/>
>            <cfset ArrayAppend(arrResult,stItem)/>            
>        </cfoutput>
>             
>             <cfreturn arrResult/>      
>  
>   
>  
>  </cffunction>
>  
> </cfcomponent>
>  
>  
> 
> -----Original Message-----
> From: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of Battershall, Jeff
> Sent: Thursday, August 11, 2005 8:38 AM
> To: [email protected]
> 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:
> 
> <cffunction name="getIndustryCategories" returntype="array"
> access="public">
>       
>             <cfset var arrResult = ArrayNew(1)/>
>             <cfset var stItem = StructNew()/>            
>             
>             <cfstoredproc procedure="sp_GetIndustryCategories"
> datasource="#getDataSource()#">
>                   <cfprocresult name="qryCats"/>
>             </cfstoredproc>      
>       
>             <cfoutput query="qryCats">
>                   <cfset stItem = StructNew()/>
>                   <cfset stItem["label"] = label/>
>                   <cfset stItem["data"] = data/>
>                   <cfset arrayAppend
(arrResult,stItem)/>            
>             </cfoutput>
>             
>             <cfreturn arrResult/>      
> 
> </cffunction>      
> 
> If you were dealing with a dynamic list of columns the code could 
be
> altered as such:
> 
> <cfoutput query="qryCats">
> 
>             <cfset stItem = StructNew()/>
> 
>             <cfloop list="#qryCats.columnList#" index="i">
>                   <cfset stItem[i] = qryCats[i][currentrow]/>
>             </cfloop>
> 
>             <cfset arrayAppend(arrResult,stItem)/>            
> 
> </cfoutput>
> 
> 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: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of Malcolm
> Sent: Wednesday, August 10, 2005 7:48 PM
> To: [email protected]
> 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: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of coldfs
> Sent: Friday, 5 August 2005 7:29 AM
> To: [email protected]
> 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:
> -----------
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml";>
> 
>       <mx:Script>
>             <![CDATA[
>                   
>                   var RecordSetModel;
> 
>                   private function doResult(event:Object):Void{
>                         var method: String = 
> event.call.methodName;
>                         if (method 
> == "GetUpdateAuthorization"){
>                               RecordSetModel = event.result;
>                         }
>                   }
>                   
>                   private function doClick():Void{
>                         var UserId = "rgatta";            
>                   
>                         var CountyCode = 37;
>                         var CaseFlag = "No";
>                         var CourtOrderAvailableFlag = "No";
>                         var Dsn = "TssDev";
>                         ro.GetUpdateAuthorization
> (UserId,CountyCode,CaseFlag,CourtOrderAvailableFlag,Dsn);
>                   }
>             ]]>
>       </mx:Script>
>       
>       
>       <mx:RemoteObject id="ro" 
> endpoint=" http://gx270dev.net/flashservices/gateway"; 
> source="Model.mUtilities.mUpdate.qry_UpdateAuthorization" 
> fault="mx.controls.Alert.show(event.fault.faultstring)" 
> showBusyCursor="true">
>             <mx:method name="GetUpdateAuthorization" 
> result="doResult(event.result)"/>
>       </mx:RemoteObject>
>       
>       <mx:Panel width="100%" title="Forms" height="22%">
>          <mx:DataGrid id="UpdatesDG" width="166" height="156" 
> wordWrap="true" dataProvider="{RecordSetModel}">
>                   <mx:columns>
>                           <mx:Array>
>                               <mx:DataGridColumn 
> width="200" headerText="Update Form" columnName="Function"/>
>                               <mx:DataGridColumn 
> width="320" headerText="Description" columnName="Description"/>
>                            </mx:Array>
>                   </mx:columns>
>             </mx:DataGrid>
>             <mx:Button label="Get Records" click="doClick()"/>
>       </mx:Panel>
>       
> </mx:Application>
> 
> --------------------------
> fx_UpdateAuthorization.cfc
> --------------------------
> <cfcomponent extends="Base">
>       
>       <cfset obj = createObject
> ("component","qry_UpdateAuthorization")>
>       
>       <!--- <cffunction name="getEmployees" access="remote" 
> returntype="array">
>             <cfreturn queryToArrayOfStructures(emp.getEmployees())
> >
>       </cffunction> --->
>       
>       <cffunction name="GetUpdateAuthorization" access="remote" 
> returntype="array">
>             <cfargument name="AuthorizedUserIdObject" 
> type="array" required="yes">
>             <cfargument name="CountyCodeObject" type="array" 
> required="yes">
>             <cfargument name="CaseFlagObject" type="array" 
> required="yes">
>             <cfargument name="CourtOrderAvailableFlagObject" 
> type="array" required="yes">
>             <cfargument name="DsnObject" type="array" 
> required="yes">
>             <cfreturn queryToArrayOfStructures
> (obj.GetUpdateAuthorization
> 
(AuthorizedUserIdObject,CountyCodeObject,CaseFlagObject,CourtOrderAva
i
> lableFlagObject,DsnObject))>
>       </cffunction>
>       
> </cfcomponent>
> 
> -----------------------------
> qry_UpdateAuthorization.cfc
> -----------------------------
> <cfcomponent extends="Base">
>       
>       <cffunction name="GetUpdateAuthorization" access="remote" 
> returntype="query">
> 
>             <cfargument name="AuthorizedUserId" type="array" 
> required="yes">
>             <cfargument name="CountyCode" type="array" 
> required="yes">
>             <cfargument name="CaseFlag" type="array" 
> required="yes">
>             <cfargument name="CourtOrderAvailableFlag" 
> type="array" required="yes">
>             <cfargument name="Dsn" type="array" required="yes">
> 
>             <CFSTOREDPROC PROCEDURE="spUpdateAuthorization" 
> DATASOURCE="#Arguments.Dsn#">
>                   <CFPROCPARAM DBVARNAME="AuthorizedUserId" 
> TYPE="IN" VALUE="#Arguments.AuthorizedUserId#" 
> CFSQLTYPE="CF_SQL_CHAR">
>                   <CFPROCPARAM DBVARNAME="CountyCode" TYPE="IN" 
> VALUE="#Arguments.CountyCode#" CFSQLTYPE="CF_SQL_CHAR">
>                   <CFPROCPARAM DBVARNAME="CaseFlag" TYPE="IN" 
> VALUE="#Arguments.CaseFlag#" CFSQLTYPE="CF_SQL_CHAR">
>                   <CFPROCPARAM 
> DBVARNAME="CourtOrderAvailableFlag" TYPE="IN" 
> VALUE="#Arguments.CourtOrderAvailableFlag#" 
CFSQLTYPE="CF_SQL_CHAR">
>                   <CFPROCRESULT NAME="qGetUpdateAuthorization">
>             </CFSTOREDPROC>
>             
>          <cfreturn qGetUpdateAuthorization>
> 
>       </cffunction>
> 
> </cfcomponent>
> 
> -------------
> Base.cfc
> -------------
> <cfcomponent>
> 
>       <cffunction name="dumpToFile" access="package" hint="A quick 
> and easy debugging utility when testing with Flash.">
>             <cfargument name="dumpObject" type="any"  
> required="yes">
>             <cfargument name="path" type="string" required="yes">
>             <cfset var varToOutput="">
>             <cfsavecontent variable="varToOutput">
>                   <cfdump var="#arguments.dumpObject#">
>             </cfsavecontent>
>             <cffile action="write" file="#arguments.path#" 
> addnewline="yes" output="#varToOutput#">      
>       </cffunction>
> 
>       <cfscript>
>       /**
>       * 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 = structKeyArray(theArray[1]);
>             //build the query based on the colNames
>             theQuery = queryNew(arrayToList(colNames));
>             //add the right number of rows to the query
>             queryAddRow(theQuery, arrayLen(theArray));
>             //for each element in the array, loop through the 
> columns, populating the query
>             for(i=1; i LTE arrayLen(theArray); i=i+1){
>                   for(j=1; j LTE arrayLen(colNames); j=j+1){
>                         querySetCell(theQuery, colNames[j], 
> theArray[i][colNames[j]], i);
>                   }
>             }
>             return theQuery;
>       }
>       </cfscript>
> 
> </cfcomponent>
> 
> 
> 
> 
> 
> 
> 
> 
> --
> 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
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> 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
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> 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
> <http://groups.yahoo.com/group/flexcoders> " on the web.
>   
> 
> *      To unsubscribe from this group, send an email to:
>   [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]
subject=Unsubscribe> 
>   
> 
> *      Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> . 
> 
> 
>   _____




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hq1s8h5/M=362335.6886445.7839731.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123880251/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

--
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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to