RE: [flexcoders] Calling ArrayStructures in CFCs from Flex

2005-08-15 Thread dfatta





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=entryentry=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,CourtOrderAvailableFlagObject,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 

RE: [flexcoders] Calling ArrayStructures in CFCs from Flex

2005-08-15 Thread Malcolm










Great, will definitely take a look, agreed,
we certainly need some sort of referenceThe dark art of Flex  CFCs.



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=entryentry=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,CourtOrderAvai
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

Re: [flexcoders] Calling ArrayStructures in CFCs from Flex

2005-08-15 Thread Tariq Ahmed






Absolumont!


Tracy Spratt wrote:

  
  

  Message
  
  

  
  
  Im 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:
  
  
  
  
  
  cfoutput
query="qGetUpdateAuthorization"
cfset stItem = StructNew()/
cfset stItem["Function"] =
#qGetUpdateAuthorization.Function#
cfset stItem["Description"] =
#qGetUpdateAuthorization.Description#
cfset arrayAppend(arrResult,stItem)/ 
/cfoutput
  
  
  
  
  
  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

2005-08-12 Thread dfatta
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?

 cfoutput 
query="qGetUpdateAuthorization" 
cfset stItem = 
StructNew()/ 
cfset stItem["label"] = 
#queryname.columnList#/ 
cfset stItem["data"] = 
data/ 
cfset 
ArrayAppend(arrResult,stItem)/ 
 /cfoutput

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

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 therecordset 
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 intoyourStructure 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: 
  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: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 
  arrResu

Re: [flexcoders] Calling ArrayStructures in CFCs from Flex

2005-08-12 Thread Jordan Snyder
cffunction returnType=DataVO[]

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? 
   
 cfoutput query=qGetUpdateAuthorization
 cfset stItem = StructNew()/
 cfset stItem[label] = #queryname.columnList#/
 cfset stItem[data] = data/
cfset ArrayAppend(arrResult,stItem)/  
  
/cfoutput 
  
 -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 
   
 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: 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:
 
 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

RE: [flexcoders] Calling ArrayStructures in CFCs from Flex

2005-08-11 Thread Battershall, Jeff
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: 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=entryentry=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

RE: [flexcoders] Calling ArrayStructures in CFCs from Flex

2005-08-11 Thread dfatta
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

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 therecordset 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 intoyourStructure 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: 
  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: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 bealtered 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)/ 
   /cfoutputProduced 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=entryentry=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" 

RE: [flexcoders] Calling ArrayStructures in CFCs from Flex

2005-08-10 Thread Malcolm
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=entryentry=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,CourtOrderAvai
lableFlagObject,DsnObject))
/cffunction

/cfcomponent

-
qry_UpdateAuthorization.cfc
-
cfcomponent extends=Base

cffunction name=GetUpdateAuthorization access=remote 
returntype=query

cfargument name=AuthorizedUserId type=array 
required=yes