Thanks Jay, Axunderwood for the prompt responses and useful suggestions.

I bound the flex grid to a coldfusion query and it is working fine now. 

I only feel bad, that I could not get it done quicker on Thursday itself.

Thanks for your advice, examples and time. 




________________________________
From: "[email protected]" <[email protected]>
To: [email protected]
Sent: Thu, September 9, 2010 2:01:56 PM
Subject: Re: [ACFUG Discuss] newbie question: storing an array variable into a 
variable whose data type is not specified

Actually, 

           [Bindable]
          private var people_info:ArrayCollection;
shoudl be outside of function myfunction


Jay Jayaraman
Central Billing Services
Financial Management and Planning
(404) 498-8453 (W)
(404) 273-7131 (C) 



From:        [email protected] 
To:        [email protected] 
Date:        09/09/2010 01:58 PM 
Subject:        Re: [ACFUG Discuss] newbie question: storing an array variable 
into a variable whose data type is not specified 

Sent by:        [email protected] 
________________________________
 


This is how you will do it

     <mx:DataGrid dataProvider="{people_info}"  .....>
               .....
  </mx:dataGrid>

In the actionscript, you will do

          [Bindable]
          private var people_info:ArrayCollection;
          people_info =  eventObj.result.people_info as ArrayCollection;

as the result from your cfc contains three elements
     people_Info
     statMsg
     status


Jay Jayaraman
Central Billing Services
Financial Management and Planning
(404) 498-8453 (W)
(404) 273-7131 (C)



From:        Chris H <[email protected]>
To:        [email protected]
Date:        09/09/2010 01:09 PM
Subject:        Re: [ACFUG Discuss] newbie question: storing an array variable 
into a variable whose data type is not specified
Sent by:        [email protected]
 
________________________________



Thanks Steve, Jay, Clark and Axunderwood for the prompt responses and useful 
suggestions.

1.  I have changed the return type of function to "struct" and other changes in 
the function as below according to the suggestions

<cffunction name="myfunction" access="remote" returntype="struct">
      <cfargument name="form_data" type="struct">

<cfset varresult = StructNew() />
<cfset varperson = "" />   <!--- Why is this needed? I did not understand this 
part. I realize the concept is to initialize variables with blank values before 
using them --->

<cfset result['dept_name'] = "some dept"
<cfset result['dept_num'] = "some dept number"
.
.......

         <cfscript>         
                ArrayAppend(peoplearray, #printPeople.empID#);
                ArrayAppend(peoplearray, #printPeople.departmentname#);
                ArrayAppend(peoplearray, #printPeople.departmentID#);
                ArrayAppend(peoplearray, #printPeople.empTitle#);
        </cfscript>

.        <cfset result['people_info'] = peoplearray  

              <cfset result['statMsg'] = 'Information successfully collected.'>
              <cfset result['status'] = true>

   <cfreturn result>

</cffunction>

Rest of part is same as I posted earlier

2. How would I reference the return values in the caller function which is a 
Flex component?

private function myfunction(eventObj:ResultEvent):void{

             var people_obj:Object = new Object();

              people_obj.dept_name = eventObj.result.dept_name;
              people_obj.dept_num = eventObj.result.dept_num;
     
             // would the below code work? 
             
            people_obj.peoplearray = eventObj.result.peoplearray 

  }

// How can I access the department name, department ID and employee ID, title 
of 
 the third person whose name is John from the above people_obj // object?

// Or, do I need an arraycollection variable 

          [Bindable]
          private var people_info:ArrayCollection;
          people_info =  eventObj.result.peoplearray 

Then, I could load the arraycollection variable people_info into a DataGrid 
element where the elements would be displayed in order? 


Can someone please advise?

Thanks 

      


 
________________________________
From: Steve Ross <[email protected]>
To: [email protected]
Sent: Thu, September 9, 2010 9:55:29 AM
Subject: Re: [ACFUG Discuss] newbie question: storing an array variable into a 
variable whose data type is not specified

yep, what you are actually doing is creating a named struct (hash) when you do 
this:

<cfset result['people_info'] = peoplearray />

changing the return type will give you exactly what you want (unless you want 
an 
array), and if you do then you can create an array of structs... 


On Thu, Sep 9, 2010 at 9:51 AM, Chris H <[email protected]> wrote:
Hi All,

I am a newbie to Coldfusion. My development background is mainly in C/C++ so 
please excuse me if my below question is naive.  

I have a function as below

<cffunction name="myfunction" access="remote" returntype="any">
      <cfargument name="form_data" type="struct">

<!---  The variable to be returned by the function is "result"  --->

<cfset result['dept_name'] = "some dept"
<cfset result['dept_num'] = "some dept number"

<!---  I run a query where I want to find some information about people having  
name "John" and there can be N number of people with the name of John --->


<cfquery dbtype="query" name="printPeople">
  SELECT *
  FROM people
  WHERE peopleName = "John"
</cfquery>

<cfset peoplearray=ArrayNew(1)>

    <cfset myCounter = 0 />
       <cfloop query="printPeople">
          
         <cfset myCounter = myCounter + 1 />
                                              

        <cfscript>         
                ArrayAppend(peoplearray, #printPeople.empID#);
        </cfscript>

        <cfscript>         
                ArrayAppend(peoplearray, #printPeople.departmentname#);
        </cfscript>


        <cfscript>         
                ArrayAppend(peoplearray, #printPeople.departmentID#);
        </cfscript>


        <cfscript>         
                ArrayAppend(peoplearray, #printPeople.empTitle#);
        </cfscript>

        </cfloop>



              <cfset result['people_info'] = peoplearray <!--- Can this be 
done? 
--->

              <cfset result['statMsg'] = 'Information successfully collected.'>
              <cfset result['status'] = true>

   <cfreturn result>

</cffunction>


The part <cfset result['people_info'] = peoplearray
attempts to store an array variable into a variable whose data type is not 
specified.

Can this be done?

If not, what should I do? Should I define the datatype of "result" variable as 
a 
structure, change the return type
in function signature as a structure from any as a structure variable
can hold string, integer and array variables?

Any suggestions would be appreciated.


------------------------------------------------------------- 
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
------------------------------------------------------------- 



-- 
Steve Ross
web application & interface developer
http://blog.stevensross.com
[mobile] (912) 344-8113
[ AIM / Yahoo! : zeriumsteven ] [googleTalk : nowhiding ]


------------------------------------------------------------- 
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
------------------------------------------------------------- 


------------------------------------------------------------- 
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
-------------------------------------------------------------  

 
------------------------------------------------------------- 
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform 

For more info, see http://www.acfug.org/mailinglists 
Archive @ http://www.mail-archive.com/discussion%40acfug.org/ 
List hosted by FusionLink 
------------------------------------------------------------- 


      


-------------------------------------------------------------
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Reply via email to