old thread here...but...I just built a example app for my team here to share some Flex luv.  Its a simple plain-jane datagrid populated with 500 rows from a database.  I made three versions of the app:
1) Using remoteobject and typed objects CFC to AS.
2) Using a REST call to return XML via a HTTPService
3) Using a WebService to return untyped objects, Structs.

#2 whipped the pants off 1 and was a bit faster then 3.  I was really expecting 1 to be faster with all the  AMF talk and all.  I suppose 1 has a bit of over head on bith ends though to handle the objects.

DK

On 7/25/06, Shannon Hicks <[EMAIL PROTECTED]> wrote:
Actually, if you're using 7.02, you're wasting bandwidth if you consume CFC's via webservice instead of remoteobject. When you call a CFC via a remoteobject, CF does all the conversions for you as the data passes through the flashgateway.
 
Also, when you're binding data, you should always use an ArrayCollection... using LastResult isn't reliable, according to Adobe.
 
Shan


From: [email protected] [mailto:[email protected]] On Behalf Of ericonanson
Sent: Monday, July 24, 2006 8:54 PM
To: [email protected]
Subject: [flexcoders] Re: Returning query results to flex from CFC

Using CF 7.02 and Datagrids is very easy now!

Remember that the column names come through in CAPS.

Example I wrote after the Flex Data Services session to test the speed of webservices.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application

xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

<!-- setup the webservice to call -->

<mx:WebService

id="wsc" wsdl=" http://www.getpaidtoseeads.com/seeEmail.cfc?wsdl" showBusyCursor="true" useProxy="false">

<!-- this allows for a parameter to be passed I am sending the MaxRows parameter in the cfquery tag -->

<mx:operation name="GetPostalCode" >

<mx:request xmlns="">

<MaxRow>

{cbxMaxRow.value}

</MaxRow>

</mx:request>

</mx:operation>

</mx:WebService>

<!-- this is a combo box to select the rows to bring in -->

<mx:Button label="Get Records" click="wsc.GetPostalCode.send()" left=" 412" top="10"/>

<mx:ComboBox id="cbxMaxRow" left="100" top="10">

<mx:Object label="100" value="100" />

<mx:Object label="500" value="500" />

<mx:Object label="1000" value="1000" />

<mx:Object label="10000" value="10000" />

<mx:Object label="20000" value="20000" />

<mx:Object label="40000" value="40000" />

</mx:ComboBox>

<!-- here is the easy part! see how the dataprovider is the webservice no extra arraycollection needed Format is webservice id then method or function name then lastResult-->

<mx:DataGrid id="dgEmail" width="816" height="469" dataProvider="{wsc.GetPostalCode.lastResult}" x=" 50" y="100">

<mx:columns>

<!-- see how my dataField names are in caps it will not show data without that CF and FLex work that way -->

<mx:DataGridColumn headerText="Subscriber" dataField=" PKID"/>

<mx:DataGridColumn headerText="Postal Code" dataField=" POSTALCODE"/>

<mx:DataGridColumn headerText="Province" dataField=" PROVINCE"/>

</mx:columns>

</mx:DataGrid>

</mx:Application>

 

See if that makes life easier for you and all the CFer's out there.

Kindest Regards,

 

Eric


--- In [email protected], "michrx7" <[EMAIL PROTECTED]> wrote:
>
> I am trying to populate a datagrid with results from a cfc. This
> should be simple. I have written the simply "Hello World" cfc and
> gotten the string to display, but am really struggling getting a
> query to return and display. If someone would help it would be
> appreciated.
>
> Here is my CFC (getInfo.cfc):
> <CFCOMPONENT displayname="admin_rpt_AllMembers">
> <CFFUNCTION name="getCompany" access="remote"
> returntype="query">
> <CFQUERY datasource="myDatabase" name="getMem">
> SELECT cvcontactID, cvcontactLast,
> cvcontactFirst FROM cvContact
> </CFQUERY>
> <CFRETURN getMem>
> </CFFUNCTION>
> </CFCOMPONENT>
>
> Pretty straightforward as I'm only selecting some simple info out of
> the database.
>
> Now I have my flex app that should call the cfc, return the query,
> and list the info into a simple datagrid. Now I know it's making the
> calls to the cfc (using simple Alert.show() calls), but I can't get
> the data to display.
>
> Here is my mxml flex file:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="vertical" creationComplete="initApp();">
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> import mx.rpc.events.*;
> import mx.controls.Alert;
>
> [Bindable]
> public var companyInfo:ArrayCollection = null;
>
>
> public function initApp():void
> {
> myService.getCompany();
> }
>
> public function resultHandler(event:ResultEvent):void
> {
> var p1:ArrayCollection = new ArrayCollection();
> p1.source = event.result as Array;
> companyInfo = p1;
> }
>
> ]]>
> </mx:Script>
>
> <mx:RemoteObject id="myService" destination="ColdFusion"
> source="admin_rpt_AllMembers" showBusyCursor="true">
>
> <mx:method name="getCompany" result="resultHandler
> (event)" fault="Alert.show(event.fault.message)"/>
>
> </mx:RemoteObject>
>
> <mx:DataGrid name="myGrid" id="myGrid" width="100%"
> height="100%" dataProvider="{companyInfo}">
> <mx:columns>
> <mx:DataGridColumn headerText="ID" dataField="cvcontactID"/>
> <mx:DataGridColumn headerText="Last Name"
> dataField="cvcontactLast"/>
> <mx:DataGridColumn headerText="First Name"
> dataField="cvcontactFirst"/>
> </mx:columns>
> </mx:DataGrid>
>
> <mx:Button click="initApp()"/>
>
> </mx:Application>
>
> I am completely at a loss right now on where to try and change
> anything. Thanks for the help in advance.
>


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.3/395 - Release Date: 7/21/2006


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.4/396 - Release Date: 7/24/2006




--
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it? __._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to