Great! It works just fine. Thanks again Joao. It is much appreciated.

--- In [email protected], João Fernandes <[EMAIL PROTECTED]> 
wrote:
>
> Hi again,
> 
> When using query as return type you don't need to set columnName in 
your datagridColumn in uppercase. Uppercase is just when referencing 
to structures returned from coldfusion.
> 
> João Fernandes
> Sistemas de Informação
> 
> Programador Informático
> Cofina media
> 
> Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL
> Tel (+351) 213 185 200 . Fax (+351) 213 540 370
> [EMAIL PROTECTED]
> 
> -----Original Message-----
> From: [email protected] 
[mailto:[EMAIL PROTECTED] On Behalf Of rgwilson26
> Sent: quarta-feira, 22 de Fevereiro de 2006 14:04
> To: [email protected]
> Subject: [flexcoders] Re: calling a cfc from flex
> 
> First of all I want to say thanks for your help on the last few 
> posts. I think I am almost there. 
> 
> I have my CFC now returning a query and have eliminated all errors. 
> But, when I trigger my click event it seems to return the query in 
my 
> DG however no text is visible (when you scroll over the DG it 
> highlights each item, but not text is visible). 
> 
> Also, since I am now returning a wuery I no longer need to loop 
over 
> query result and insert each record into an individual structure 
and 
> append that to an array...correct? (or is that still necessary?) I 
> did configure my CFC both ways though and got the same result...a 
DG 
> with no text, but obvisouly filled with somthing do to highlighting.
> 
> I have posted what I have so far.
> 
> Thanks,
> 
> 
> ************************
>   getPersonnel.cfc
> ************************
> <cfcomponent displayname="getPersonnel">
> <cffunction name="getPersonnel" access="remote" returntype="query">
> 
>   <cfquery name="getAllPersonnel" datasource="spotDB">
>   SELECT *
>   FROM dbo.ItemsInvolvedLOV
>   </cfquery>
> 
>   <cfreturn getAllPersonnel>
>   </cffunction>
>   </cfcomponent>
> 
> ************************
>    personnelNeeded.MXML
> ************************
> <mx:Script>
> <![CDATA[
>         public var dp:Array;
> 
>         private function doResult(result:Array):Void {
>            dp = result;
>        }
> ]]>
> </mx:Script>
> 
> 
> ************************
>    Remote Object
> ************************
> <mx:RemoteObject id="ro"
>           endpoint="http://IPADDRESS:PORT#/flashservices/gateway";
>             source="cfdocs.components.getPersonnel"
>              fault="mx.controls.Alert.show
> (event.fault.faultstring, 'Error')"
>        showBusyCursor="true">
> <mx:method name="getPersonnel" result="doResult
> (event.result._items)"/>
> 
> </mx:RemoteObject>
> 
> 
> ************************
>    Datagrid
> ************************
> 
> <mx:DataGrid id="dgPersonnelNeeded"
> height="300" width="100%" dataProvider="{dp}">
> <mx:columns>
> <mx:Array>
> <mx:DataGridColumn headerText="Name" columnName="ITEMID"
> width="225" />
> <mx:DataGridColumn headerText="Title" columnName="ITEMTITLE"
> width="650"/>
> <mx:DataGridColumn headerText="Date" columnName="ITEMDATE"
> width="100" />
> </mx:Array>
> </mx:columns>
> </mx:DataGrid>
> 
> <mx:Button label="Get Records" width="100"
> click="{ro.getPersonnel()}"/>
> 
> 
> 
> 
> 
> --- In [email protected], João Fernandes <joaofernandes@> 
> wrote:
> >
> > The error is the type you returned. You typed as string when its 
or 
> an array (of structs) or a query. Even in CF you'll have that error 
> it's not on the Flex side the problem, is your return type in your 
> CFC. 
> > 
> > João Fernandes
> > Sistemas de Informação
> > 
> > Programador Informático
> > Cofina media
> > 
> > Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL
> > Tel (+351) 213 185 200 . Fax (+351) 213 540 370
> > joaofernandes@
> > 
> > -----Original Message-----
> > From: [email protected] 
> [mailto:[EMAIL PROTECTED] On Behalf Of rgwilson26
> > Sent: terça-feira, 21 de Fevereiro de 2006 15:32
> > To: [email protected]
> > Subject: [flexcoders] Re: calling a cfc from flex
> > 
> > OK, I glad to know there is a way to just return a straight query 
> > from a CFC...that is good to know. I did change my columnName in 
my 
> > DG to all caps (is this still necessary in MX7?) and made changes 
> to 
> > my ActionScript code, however I am still getting a "value from 
> > getPersonnel() of not type string" error. 
> > 
> > Do I no longer need an array of structures in my CFC, and just 
> return 
> > a query result? Or, do I still need to put the results of the 
query 
> > into an array of structures? I did try both ways however in my 
CFC, 
> > and am still getting the same error regardless. 
> > 
> > This is what I have:
> > 
> > ************************
> >  getPersonnel.cfc
> > ************************
> > <cfcomponent displayname="getPersonnel">
> > <cffunction name="getPersonnel" access="remote" 
returntype="string">
> >             
> >  <cfset var arrayResult = ArrayNew(1)/>
> >             
> >  <cfquery name="getAllPersonnel" datasource="spotDB">
> >  SELECT * 
> >  FROM dbo.ItemsInvolvedLOV
> >  </cfquery>
> >             
> >  <cfoutput query="getAllPersonnel">
> >  <cfset structPersonnel = StructNew()/>
> >  <cfset structPersonnel["ItemId"] = #getAllPersonnel.ItemId#>
> >  <cfset structPersonnel["ItemType"] = #getAllPersonnel.ItemType#>
> >  <cfset structPersonnel["ItemName"] = #getAllPersonnel.ItemName#>
> >  <cfset arrayAppend(arrayResult,structPersonnel)/> 
> >  </cfoutput>
> >  
> >  <cfreturn getAllPersonnel>
> >  </cffunction>
> >  </cfcomponent>
> > 
> > ************************
> >   personnelNeeded.MXML
> > ************************
> > <mx:Script> 
> > <![CDATA[ 
> >        public var dp:Array;
> >             
> >        private function doResult(result:Array):Void {
> >                 dp = result;
> >             }
> > ]]> 
> > </mx:Script> 
> >      
> > 
> > ************************
> >   Remote Object
> > ************************ 
> > <mx:RemoteObject id="ro" 
> >        endpoint="http://IPADDRESS:PORT#/flashservices/gateway";  
> >          source="cfdocs.components.getPersonnel"
> >           fault="mx.controls.Alert.show
> > (event.fault.faultstring, 'Error')" 
> >     showBusyCursor="true">
> > <mx:method name="getPersonnel" result="doResult
> > (event.result._items)"/>
> >             
> > </mx:RemoteObject>
> > 
> > 
> > ************************
> >   Datagrid
> > ************************
> > 
> > <mx:DataGrid id="dgPersonnelNeeded" headerColor="#00CC33" 
> > height="300" textAlign="left" width="100%" wordWrap="true" 
> > editable="true" dataProvider="{dp}">
> > <mx:columns>
> > <mx:Array>
> > <mx:DataGridColumn headerText="Name" columnName="ITEMID" 
> > width="225" />
> > <mx:DataGridColumn headerText="Title" columnName="ITEMTITLE" 
> > width="650"/>
> > <mx:DataGridColumn headerText="Date" columnName="ITEMDATE" 
> > width="100" />
> > </mx:Array>
> > </mx:columns>
> > </mx:DataGrid> 
> > 
> > <mx:Button label="Get Records"  textAlign="center" width="100" 
> > click="{ro.getPersonnel()}"/>
> >  
> > 
> > 
> > 
> > 
> > 
> > 
> > --- In [email protected], "Stacey Mulcahy" <stacey@> 
> > wrote:
> > >
> > > 
> > > Yep you'll need caps.
> > > 
> > > 
> > > -----Original Message-----
> > > From: [email protected] 
> > [mailto:[EMAIL PROTECTED] On
> > > Behalf Of João Fernandes
> > > Sent: Friday, February 17, 2006 4:48 PM
> > > To: [email protected]
> > > Subject: RE: [flexcoders] calling a cfc from flex
> > > 
> > > 
> > > Welcome first of all,
> > > 
> > > I don't know if you are aware that you can return directly a 
> query 
> > from the
> > > CFC. In flex side it will be available as event.result._items 
and 
> > you are
> > > able to bind it directly as an Array.
> > > 
> > > In your sample you could say in cfc:
> > > 
> > > <cfreturn getAllPersonnel>
> > > 
> > > in your mxml file you could have some 
> > > public var dp:Array;
> > > private function doResult(result:Array):Void {
> > >           dp = result;
> > >     }
> > > 
> > > in the Datagrid set the property dataProvider="{dp}"
> > > and just replace your remote object result to
> > > result="doResult(event.result._items)"
> > > 
> > > I think, if I'm not mistaken, your datagridcolumns should have 
> > columnName in
> > > upper case when dealing with CFC structures.
> > > 
> > > Regards,
> > > 
> > > João Fernandes
> > > 
> > > -----Original Message-----
> > > From: [email protected] on behalf of rgwilson26
> > > Sent: Fri 17-Feb-06 6:11 PM
> > > To: [email protected]
> > > Subject: [flexcoders] calling a cfc from flex
> > >  
> > > I am new to flex and working on calling a cfc that has a simple 
> > query 
> > > in it. I want my query to populate a datgrid with all pertinant 
> > > information. I am having a hard time converting from an array 
to 
> a 
> > > string to populate the DG. Any help in what I am missing would 
be 
> > > great, or if there is an easier way to call a query and return 
> data 
> > > would be great!
> > > 
> > > ************************
> > >   getPersonnel.cfc
> > > ************************
> > > <cfcomponent displayname="getPersonnel">
> > > <cffunction name="getPersonnel" access="remote" 
> returntype="string">
> > >           
> > > <cfset var arrayResult = ArrayNew(1)/>
> > >           
> > > <cfquery name="getAllPersonnel" datasource="spotDB">
> > > SELECT * 
> > > FROM dbo.ItemsInvolvedLOV
> > > </cfquery>
> > >           
> > > <cfoutput query="getAllPersonnel">
> > > <cfset structPersonnel = StructNew()/>
> > > <cfset structPersonnel["ItemId"] = #getAllPersonnel.ItemId#>
> > > <cfset structPersonnel["ItemType"] = #getAllPersonnel.ItemType#>
> > > <cfset structPersonnel["ItemName"] = #getAllPersonnel.ItemName#>
> > > <cfset arrayAppend(arrayResult,structPersonnel)/> 
> > > </cfoutput>
> > > <!--- Return Array to Flex--->
> > > <cfreturn getAllPersonnel>
> > > </cffunction>
> > > </cfcomponent>
> > > 
> > > 
> > > ************************
> > >   personnelNeeded.MXML
> > > ************************
> > > ActionScript:
> > > ------------
> > > private function doResult(result:Array):Void {
> > >           
> > >     var personnelObject:Object = new Object();  object 
> > >     var personnelResult:Array = new Array();    
> > > 
> > >     for(var i=0; i < result.length; i++){
> > >      personnelObject = result[i];
> > >      personnelResult.push(personnelObject);
> > >     }
> > >     dgPersonnelNeeded.dataProvider = personnelResult;
> > >     }
> > > 
> > > ************************
> > >   Remote Object
> > > ************************
> > > 
> > > <mx:RemoteObject id="ro" 
> > >      endpoint="http://10.95.20.39:8500/flashservices/gateway";  
> > >        source="cfdocs.components.getPersonnel"
> > >         fault="mx.controls.Alert.show
> > > (event.fault.faultstring, 'Error')" 
> > >   showBusyCursor="true">
> > > <mx:method name="getPersonnel" result="doResult(event.result)"/>
> > >           
> > > </mx:RemoteObject>
> > > 
> > > 
> > > ************************
> > >   Datagrid
> > > ************************
> > > 
> > > <mx:DataGrid id="dgPersonnelNeeded" headerColor="#00CC33" 
> > > height="300" textAlign="left" width="100%" wordWrap="true" 
> > > editable="true">
> > > <mx:columns>
> > > <mx:Array>
> > > <mx:DataGridColumn headerText="Name" columnName="name" 
> > width="225" />
> > > <mx:DataGridColumn headerText="Title" columnName="title" 
> > width="650"/>
> > > <mx:DataGridColumn headerText="Date" columnName="date" 
> > width="100" />
> > > </mx:Array>
> > > </mx:columns>
> > > </mx:DataGrid> 
> > > 
> > > 
> > > ************************
> > >   Click event button
> > > ************************
> > > <mx:Button label="Get Records"  textAlign="center" width="100" 
> > > click="{ro.getPersonnel()}"/>
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --
> > > 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
>






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