Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Database Access / August 2008



Tip: Looking for answers? Try searching our database.

I am having trouble parsing out the qstructs as array collections in flex

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nikos101 - 28 Aug 2008 11:37 GMT
I have a function that returns a struct:

<cffunction name="getChartData" access="remote" returntype="struct">
        <cfargument name="userID"        required="true" type="numeric">
        <cfquery name="chart" datasource="#datasource#">
            select    *
            from data where  userID     = <cfqueryparam value="#arguments.userID#"
    cfsqltype="cf_sql_integer">   
        </cfquery>
        <cfquery name="comments" datasource="#datasource#">
            select    comment,dateAdded
            from    comments where  userID     = <cfqueryparam value="#arguments.userID#"
    cfsqltype="cf_sql_integer">   
        </cfquery>
        <cfset struct.chart = chart>
        <cfset struct.comments = comments>
        <cfset flash.result = struct>
    <cfreturn flash.result>
</cffunction>

I am having trouble parsing out the qstructs as array collections in flex as
follow:

        private function handleChartData(event:ResultEvent):void{
           
                   var fullArray:ArrayCollection = event.result.chart as
ArrayCollection ;
     
                comments.dataProvider = event.result.comments as ArrayCollection ;
                debug.dataProvider = fullArray;
     
         }

Is there anything that I am doing wrong?
PaulH **AdobeCommunityExpert** - 28 Aug 2008 12:07 GMT
> I have a function that returns a struct:

which, unless you create a specific class for it, flex side will map as an Object.
nikos101 - 29 Aug 2008 10:41 GMT
So in the above example I expect the flex object the struct maps to client side
contains two array collections:

struct
{chart ,comments}

How to I access these values without creating a specific class?
PaulH **AdobeCommunityExpert** - 29 Aug 2008 10:57 GMT
> So in the above example I expect the flex object the struct maps to client side
> contains two array collections:
>
>  struct
>  {chart ,comments}

it should.

>  How to I access these values without creating a specific class?

private function handleChartData(event:ResultEvent):void{
    comments.dataProvider = event.result.comments as ArrayCollection ;
}

might be Array instead of ArrayCollection. also watch out for CAsE coming from cf.
nikos101 - 29 Aug 2008 11:18 GMT
might be Array instead of ArrayCollection. also watch out for CAsE coming from
cf.

It should be an ArrayCollection becase there are multiple column in the table
being queried.
I still am not getting anything showing up on my charts when i do

comments.dataProvider = event.result.comments as ArrayCollection ;

However when I don't return a stuct as shown below my datagrid works fine:

<cffunction name="getChartData" access="remote" returntype="query">
        <cfargument name="userID"        required="true" type="numeric">
       
        <cfquery name="chart" datasource="#datasource#">
            select    *                                     
            from    staff_charts_data where  userID     = <cfqueryparam
value="#arguments.userID#"     cfsqltype="cf_sql_integer">   
        </cfquery>
       
       
        <cfquery name="comments" datasource="#datasource#">
            select    comment,dateAdded
            from    staff_charts_comments where  userID     = <cfqueryparam
value="#arguments.userID#"     cfsqltype="cf_sql_integer">   
        </cfquery>
       
        <cfset flash.result = comments>
    <cfreturn flash.result>
</cffunction>

comments.dataProvider = event.result as ArrayCollection ;

btw Thanks  very much for your gelp so far Paul :)
nikos101 - 29 Aug 2008 11:31 GMT
Sorted please see this post

http://www.kylehayes.info/blog/index.cfm/2007/5/14/ColdFusion-Struct-to-Flex-Unt
yped-Object-Gotcha

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.