Flex 4 & Remoting

First the ColdFusion component has not changed

<cfcomponent displayName= "testConn">
	<!--- Establish a Flash Remoting Connection --->
	<cffunction name="getTestConn" access="remote" returnType="string">
        <cfreturn "connection to the ColdFusion 9 Server was successful">
   </cffunction>
</cfcomponent>

The Flex code is a little different and strangely I get quotes return here in the text field, but the same code ran in Flash or even Flex 3 returns no quotes.

The Flex Code with using the Flex 4 SDK & Spark

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	<fx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.utils.ObjectUtil;

			private function getTestConn_handler( event:ResultEvent):void {
				Result.text = ObjectUtil.toString(event.result);
			}
		]]>
	</fx:Script>

	<fx:Declarations>
		<mx:RemoteObject id="testConn" destination="ColdFusion" source="testConn">
			<mx:method name="getTestConn" result="getTestConn_handler(event)" />
		</mx:RemoteObject>
	</fx:Declarations>

	<mx:Label id="Result" x="127" y="22" width="395" textAlign="left" fontFamily="Verdana" color="#655E5E"/>
	<mx:Button x="10" y="21" label="Test Connection" click="testConn.getTestConn()"  cornerRadius="5" focusColor="#E6EBF0" chromeColor="#F4F6FA" width="109"/>

</s:Application>

So what has changed in remoting in the new Flex SDk & Flash Builder 4? Not much really.

  • New namespaces
  • the script is wrapped in <fx:Script>
  • the mx:RemoteObject is placed in the  <fx:Declarations>
  • afterwards I have a button and a text field which gets the data from the cfc

okay everything is working, but for the life of me I can get rid of the quote:(


Any ideas to this?

Flex 4 & Remoting

First the ColdFusion component has not changed

<cfcomponent displayName= "testConn">
	<!--- Establish a Flash Remoting Connection --->
	<cffunction name="getTestConn" access="remote" returnType="string">
        <cfreturn "connection to the ColdFusion 9 Server was successful">
   </cffunction>
</cfcomponent>

The Flex code is a little different and strangely I get quotes return here in the text field, but the same code ran in Flash or even Flex 3 returns no quotes.

The Flex Code with using the Flex 4 SDK & Spark

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	<fx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.utils.ObjectUtil;

			private function getTestConn_handler( event:ResultEvent):void {
				Result.text = ObjectUtil.toString(event.result);
			}
		]]>
	</fx:Script>

	<fx:Declarations>
		<mx:RemoteObject id="testConn" destination="ColdFusion" source="testConn">
			<mx:method name="getTestConn" result="getTestConn_handler(event)" />
		</mx:RemoteObject>
	</fx:Declarations>

	<mx:Label id="Result" x="127" y="22" width="395" textAlign="left" fontFamily="Verdana" color="#655E5E"/>
	<mx:Button x="10" y="21" label="Test Connection" click="testConn.getTestConn()"  cornerRadius="5" focusColor="#E6EBF0" chromeColor="#F4F6FA" width="109"/>

</s:Application>

So what has changed in remoting in the new Flex SDk & Flash Builder 4? Not much really.

  • New namespaces
  • the script is wrapped in <fx:Script>
  • the mx:RemoteObject is placed in the  <fx:Declarations>
  • afterwards I have a button and a text field which gets the data from the cfc

okay everything is working, but for the life of me I can get rid of the quote:(


Any ideas to this?

FDT Remoting Template

This is meant to test a remoting connection with a ColdFusion back-end

The ColdFsuion Code has been tested and works. Here is the cfc that I am using


<cfcomponent displayName="getTest">
 <!--- Establish a  Flash Remoting Connection --->
     <cffunction  name="getTestConn" access="remote" returnType="string" output="true">
        <cfreturn "....connection successful">
     </cffunction>
 </cfcomponent>

The rest is actionscript!

import flash.net.*;

var gateway:NetConnection = new NetConnection();
var responder:Responder=new Responder(onResult,onFault);

function onResult(responds:Object):void {
    trace("cfc result"+":"+" "+responds.toString());
}

function onFault(responds:Object):void {
    //loop over the fault structure
    for (var i:String in responds) {
        trace( i + ":" + responds[i] );

    }
}

// name the default cf test server on this machine
gateway.connect("http://localhost/flashservices/gateway/");

// name of the cfc and the function in it that you want to hit in dot notation
gateway.call("com.cfcs.getTest.getTestConn", responder/*this is where any arguments to the remote call go*/)

Now I am attempting to make a template for this in FDT, it works fine in the Flash IDE, but I really don’t want to use the IDE for coding, as I really like FDT for coding!

Now this is the exact code, but I will try to figure out how to use the template propties in FDT to figure out how to change the names of the function, where the cfc is to varaibales, as these will not always be the same. This is just a test to see if you were able to connect to the gateway.

This does work when I dump it into my class, but I get a starnage error

the error panel tells me (click on image for bigger image)

the part besides the template I don’t get, if I have access to the flash.net package in FDT why would I recieve these errors? Works fine in the Flash IDE, but not in FDT.

You can see the post for setting this up for the Flash IDE here
http://hawaiiflash.net/blog/post.cfm/flash-remoting Download the code put the com folder in your CF webroot, open the fla and run just tested and works fine.

UPDATE

package {
    import flash.events.NetStatusEvent;
    //import flash.display.Sprite;
    import flash.net.NetConnection;
    import flash.net.Responder;

    /**
     * @author johnbarrett
     */

    public class Remoting extends NetConnection {

        //set up the variables for the connetion and the responder
        private static var _gateway : NetConnection = new NetConnection();
        private static var _responder : Responder =new Responder(onResult,onFault);

        //use protected to not get an error
        protected var responds : Object;

        private static function onFault(responds:Object) : void {
            //loop over the fault structure
            for (var i:String in responds) {
                trace( i + ":" + responds[i] );
            }
        }

        private static function onResult(event : NetStatusEvent) : void {
            var responds : Object;
            trace(responds.toString());
        }

        // name the default cf test server on this machine

        _gateway.connect("http://localhost/flashservices/gateway/");

        // name of the cfc and the function in it that you want to hit in dot notation
        _gateway.call("com.cfcs.getTest.getTestConn", _responder);
    }
}

this gets rid of the all the errors in FDT, but I do get an warning witht he .toString();

However, when I run the example I get the compile error:

[Info] Connection to player established.

Exception fault: Error: Error #2132: NetConnection.connect cannot be called from a netStatus event handler.

    at flash.net::NetConnection/connect()
    at Remoting$cinit()
    at global$init()[/Users/johnbarrett/Documents/workspace/Remoting/src/Remoting.as:13]

 

Getting Database Results into Flex

So I had a fight with Flex tonight, and I won! Well kind of I did let Flex tell me what to name my method, and then we played nice with ColdFusion. The first part is my strange mistake with Flex & ColdFusion getting my database results into a flex datagrid. Afterward I changed the method name to not be plural, and I was able to bind my query into a flex datagrid. I am happy that I got it woring in the end!

I am using ColdFusion 9, with the database that ships with ColdFusion 9.

first make sure you set up ColdFuson with Remoting in you Flex project

First I build the component


<cfcomponent>

    <cffunction name="getArtists" access="remote" returntype="query">
        <cfset var qRead = "" />

        <cfquery datasource="cfartgallery" name="qRead">
            SELECT artistid, firstname, lastname, email
            FROM artists
        </cfquery>

        <cfreturn qRead />
    </cffunction>

</cfcomponent>

I usually like to test to see if the ColdFusion component is working properly


  <cfinvoke
     component="ArtistGateway"
     method="getArtists"
     returnVariable="qRead">

     <!--- dump the output--->
     <cfdump  var = "#qRead#">

The cfdump gives the data results expected from the database

Now the Flex part


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">

    <mx:Script>
        <![CDATA[

            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;

            [Bindable]
            private var acArtists:ArrayCollection;

            private function initApp() :void {
                ArtistGateway_RO.getArtist();
            }

            private function getArtistsRO_Handler(event:ResultEvent):void {
                acArtists = ArrayCollection(event.result);
            }
        ]]>
    </mx:Script>

    <mx:RemoteObject id="ArtistGateway_RO" destination = "ColdFusion" source ="com.cfcs.ArtistGateway">
        <mx:method name="getArtists" result = "getArtistsRO_Handler(event)" />
    </mx:RemoteObject>

    <mx:DataGrid dataProvider = "{acArtists}" right="10" left="10" top="10" bottom="10">
    </mx:DataGrid>

</mx:Application>

Flash player gives me the error

Now I have checked ant the ArtistGateWay.cfc is located in my webroot http://localhost/com/cfcs/ArtistgateWay.cfc and I think that flex looks from the webroot, in my case localhost, so I think that I have the settings right as “com.cfcs.ArtistsGateWay” the strange part is that it is looking for a method “getArtisit” but the method is getArtists

You can download source here

UPDATED– CODE IS FIXED

This is very strange, I changed the method name in the componet to be getArtist, along with the methos name in mx:method and now everything is working!

I did make one extra change to display a friendly error message using the Alerts in Flex

This is done by adding the fault event

First import the necessary classes


import mx.rpc.events.FaultEvent;
import mx.controls.Alert;

In the block add


private function result(event:ResultEvent):void {
    Alert.show(event.toString());
}

private function fault(event:FaultEvent):void {
    Alert.show("Error while calling cfc: nn" + event.fault.message);
}

You will notice I have 2 line breaks (nn) in the Alert.show to give a little spacing, which I find this easier to read!

finally to use the alert add the fault event in , so that the mx:method looks like this


<mx:method name="getArtist" result = "getArtistsRO_Handler(event)" fault="fault(event)" />

Okay now lets go over the correct code

The Flex application


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">

    <mx:Script>
        <![CDATA[

            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;
            import mx.rpc.events.FaultEvent;
            import mx.controls.Alert;

            [Bindable]
            private var acArtists:ArrayCollection;

            private function initApp() :void {
                ArtistGateway_RO.getArtist();
            }

            private function result(event:ResultEvent):void {
                  Alert.show(event.toString());
            }

            private function fault(event:FaultEvent):void {
                  Alert.show("Error while calling cfc: nn" + event.fault.message);
            }

            private function getArtistsRO_Handler(event:ResultEvent):void {
                acArtists = ArrayCollection(event.result);
            }
        ]]>
    </mx:Script>

    <mx:RemoteObject id="ArtistGateway_RO" destination = "ColdFusion" source ="QueryToDataGrid-debug.cfcs.ArtistGateway">
        <mx:method name="getArtist" result = "getArtistsRO_Handler(event)" fault="fault(event)" />
    </mx:RemoteObject>

    <mx:DataGrid dataProvider = "{acArtists}" right="10" left="10" top="10" bottom="10">
    </mx:DataGrid>

</mx:Application>

The ColdFusion componet


<cfcomponent>

    <cffunction name="getArtist" access="remote" returntype="query">
        <cfset var qRead = "" />

        <cfquery datasource="cfartgallery" name="qRead">
            SELECT artistid, firstname, lastname, email
            FROM artists
        </cfquery>

        <cfreturn qRead />
    </cffunction>

</cfcomponent>

I have no idea why Flex would not let me use getArtists and would only work using getArtist, maybe it is a caching issue, or just flex does not like plural methods!

Where is the finally correct code if you are interested in using it

The final Flex datagrid

One final update

Flex does not have an issue with plural methods, it was a silly typo of mine!
I would like to thank Paul Hastings from the  CF -Talk mailing list for correcting my problem!
He pointed out, “your error is flex side, your init method is trying to call getArtist() which  doesn’t exist on that service.”

Now everything makes sense, thanks Paul!

I was able to figure this out, and I even figured out how to use the Alerts for an error message, so all in all a good night with Flex & ColdFusion:)

Remoting with Flex 3

Coldfusion component


<cfcomponent>
<cffunction name="GetHello" output="false" access="remote" returntype="string">
    <cfreturn "Hello World">
    </cffunction>
</cfcomponent>

Flex


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

    <mx:Script>
        <![CDATA[
            import mx.rpc.events.ResultEvent;
            import mx.utils.ObjectUtil;

            private function GetHello_handler( event:ResultEvent):void {
                Result.text = ObjectUtil.toString(event.result);
            }
        ]]>
    </mx:Script>

    <mx:RemoteObject id="helloWorld" destination="ColdFusion" source="HelloWorld">
        <mx:method name="GetHello" result="GetHello_handler(event)" />
    </mx:RemoteObject>

    <mx:Label id="Result" x="59" y="58" width="87"/>
    <mx:Button x="154" y="56" label=" Get Hello" click="helloWorld.GetHello()" />
</mx:Application>

Setting up Flash Remoting with AS 3 & ColdFusion

Setting up flash remoting with actionscript 3.0 and ColdFusion
Create a fla, call it remoting(or something that makes sense to you).

In the actions, type the following code

import flash.net.*;
var gateway:NetConnection = new NetConnection();
var responder:Responder=new Responder(onResult,onFault);

function onResult(responds:Object):void {
    trace("cfc result"+":"+" "+responds.toString());
}

function onFault(responds:Object):void {
    //loop over the fault structure
    for (var i:String in responds) {
        trace( i + ":" + responds[i] );

    }
}

// name the default cf test server on this machine
gateway.connect("http://localhost/flashservices/gateway/");

// name of the cfc and the function in it that you want to hit in dot notation
gateway.call("com.cfcs.getTest.getTestConn", responder/*this is where any arguments to the remote call go*/);

The cfc lives on my localhost/com/cfcs/gettestConn.cfc

The cfc will look like this

<cfcomponent displayName="getTest">
  <!--- Establish a Flash Remoting Connection --->
  <cffunction name="getTestConn" access="remote" returnType="string" output="true">
    <cfreturn "....connection successful">
   </cffunction>
 </cfcomponent>

When you run your flash file you should see this in the output window

download project

Move com folder to your ColdFusion localhost host, if you are running the default set up you will need to change the port to 8500. Then run the fla file, you should be fine, with flash & ColdFusion working together!

Any question, problems? Let me know I will try to help.
I will posting another example on how to display the results from your cfc, and later how to pull database results into your flash movie as well.

AS3 Debug Issues!

I have been making progress on getting the AS 3 debugger working in Flash CS 3.

I have a remoting project(it could be anything I want to debug)

Here is my actions panel, with the break point

debug

When I try to debug movie I get this error:


Attemping to launch and connect to Player using URL /Users/johnbarrett/Desktop/downloads/remoting_debug.swf

[SWF] Users:johnbarrett:Desktop:downloads:remoting_debug.swf - 1635 bytes after decompression

Warning: Domain 127.0.0.1 does not specify a meta-policy.  Applying default meta-policy 'all'.  This configuration is deprecated.  See http://www.adobe.com/go/strict_policy_files to fix this problem.

Warning: Domain localhost does not specify a meta-policy.  Applying default meta-policy 'all'.  This configuration is deprecated.  See http://www.adobe.com/go/strict_policy_files to fix this problem.

before running this I change the file FlashAuthor.cfg to include User

# FlashAuthor.cfg

#

# This file was automatically installed with one or more

# Macromedia applications. This file directs Macromedia Flash

# Player to provide alternate messaging for violations of the

# security rules for local .SWF files. The alternate messaging

# is designed for users who are authors of .SWF files rather

# than only consumers of them.

#

# If you are creating .SWF files for deployment as local files

# rather than for Web delivery, and you need to simulate the

# end-user experience for local security problems, try changing

# the value of "LocalSecurityPrompt" below to "User" rather

# than its default of "Author".

#

# For more information, see:

# http://www.macromedia.com/go/flashauthorcfg

#
LocalSecurityPrompt=User

now in the crossdomain.xml I have


<?xml version="1.0"?>

<!-- http://127.0.0.1/crossdomain.xml -->

<cross-domain-policy>

    <allow-access-from domain="127.0.0.1" to-ports="507" />

    <allow-access-from domain="*" to-ports="*" />

 </cross-domain-policy>

Flash Remoting Query is fixed!

The flash remoting issues that I was having is now fixed! The solution was to realize that there is no record set in AS 3, and it is an arrayCollection, and this is why I think that I was getting the [object] returned when I tried to trace the results.

I am so very thankful to flash-db for posting the picture of the Charles debug tool, otherwise I would have never figured this out. I was able to see the name of the headers from their screen shot, but I have yet to figure out Charles myself

Charles

As you can see I needed the serverInfo.initialData

Here is my solution

//Import the classes

import flash.net.*;



//connect to the gateway

var gateway:NetConnection = new NetConnection();

var responder:Responder=new Responder(onResult,onFault);



// name the default cf test server on this machine

gateway.connect("http://localhost/flashservices/gateway/");



// name of the cfc and the function

gateway.call("com.cfcs.testing.GetResults", responder);



function onResult(responds:Object):void {

		var recordcount:Number = responds.serverInfo.totalCount

		//display the total records in the database(recordcount)

		trace("There are"+" "+recordcount+" "+"Members of the Hawaii Flash User Group:"+"n");

		//loop through the records in the database

    	for(var i:Number = 0; i<recordcount; i++){

			var query = responds.serverInfo.initialData;

			//display the results from the database

			trace(query[i]+"n");

		}

}



function onFault(responds:Object):void {

	//loop over the fault structure

	for (var i:String in responds) {

		trace( i + ":" + responds[i] );

	}

}

flash Remoting & Query

I asked on CF Talk ( Cf-Flash) for some help on remoting, and Tyron Foston came up with a great solution


How To Use the AS3 FlashRemoting Class



1) Create an instance of the FlashRemoting class

   -The constructor takes the location of the flash

   remoting servcie as its only parameter



2) Set a "onLoad" handler to handle the results coming

   from the server



3) Use the "load" function to send a flash remtoing call

   to the coldfusion server. This takes 2 parameters

   a) the cfc and function you want to call

   b) parameter. This only takes 1 parameter. If you want

      to pass multiple variables, place then into an object

      and pass the object



4) There is a function called "toQuery" that takes a recordset

   from coldfusion and turns it into an object with index arrays







Working Example

---------------------------------------------------------------

//Create an indexed array with values,

//this will be the parameters passed to the coldfusion server

var array = new Array()

array[0] = 'car'

array[1] = 'boat'

array[2] = 'ship'



//Create new instance of the FlashRemoting Class

var fr:FlashRemoting =

new FlashRemoting('http://www.mydomain.com/flashservices/gateway')



//Set the onLoad handler for when the flash gets the server response

fr.onLoad = function(obj){



	//I'm expecting a query, so use the "toQuery" function

	var myQuery = this.toQuery(obj)



}



//Call the method on the remoting cfc (relative to the gateway url)

fr.load('nameOfCFC.nameOfFunction', array)




package{



	//Import needed classes

	import flash.events.*

	import flash.net.NetConnection

   	import flash.net.ObjectEncoding;

    import flash.net.Responder;

	import flash.display.MovieClip;



	//Create new public class

	public dynamic class FlashRemoting{



		//Set Class variables



		//Set class variable for the netConnection

		private var nc:NetConnection





		/*

		Create the constructor function taking the remote server URL

		as the only function parameter

		*/

		public function FlashRemoting(url:String){



				//Create netConnection object and event listeners

				this.nc = new NetConnection()



				//Set the AMF encoding method

				this.nc.objectEncoding = ObjectEncoding.AMF0



				//Set the netConnection client property to this class to handle all

				this.nc.client = this



				//Make the connection to the remote server

				this.nc.connect(url)



				//Set the event listener to listen for net_status events

				this.nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus)



		}





		/*

		The function to be invoked when there is a connection problem.

		The event information is passed to the onLoad function

		*/

		private function onNetStatus(event){

			//trace("Event:"+event)

			var obj:Object = event.info

			//trace(""+event)

			for(var i in event){

				//trace(i+":"+event[i])

			}

			this.onLoad(obj)

		}







		/*

		Makes a call to the remote server. The first parameter

		is the location.method to call on the cfc

		The second paramter is an array of parameter for the

		remote method to consume

		*/

		public function load(method:String, args){

			//Call the method on the server

			var responder = new Responder(this.getResult, this.getError);

			this.nc.call(method, responder, args)

		}







		/*

		The function that gets called if everything goes right

		This function passes the result from the server, to

		the onLoad function

		*/

		private function getResult(obj){

				try{

					//trace("getResult")

					this.onLoad(obj)

				}

				catch(e){

					//Do Nothing

				}

		}



		/* The function that gets called with things go

		wrong. The String 'ERROR' is always passed to the

		onLoad function

		*/

		private function getError(obj){

				try{

					this.onError(obj)

				}

				catch(e){

					//Do Nothing

				}

		}





		public function toQuery(obj:Object):Object{





			//trace(serverData.columnNames)

			//trace("Version:"+serverData.version)

			//trace("Cursor:"+serverData.cursor)

			//trace("Total Count:"+serverData.totalCount)

			//trace("Inital Data:"+serverData.initialData[0][1])



			var serverData = obj['serverInfo']

			var columns:String = serverData.columnNames

			var columnArray = columns.split(',')

			var columnObj = new Object()

			var query = new Object()

			var totalRows:Number = serverData.totalCount

			var currentRow:Number = 0

			var a:Number



			//Create tmp columns arrat and begin query structure

			for(a=0; a<columnArray.length; a++){

				columnObj[columnArray[a]] = a

				query[columnArray[a]] = new Array()

			}





			//Loop through the initalData property (query data)

			for(a = 0; a < columnArray.length; a++){

				for(currentRow = 0; currentRow < totalRows; currentRow++){

					query[columnArray[a]][currentRow] = serverData.initialData[currentRow][a]

				}

			}



			//Return the query object

			return query

		}





	}//end class



}//end package



The main flash file


//Create an indexed array with values, this will be the parameters passed to the coldfusion server



var array = new Array()

array[0] = 'car'

array[1] = 'boat'

array[2] = 'ship'



//Create new instance of the FlashRemoting Class

var fr:FlashRemoting = new FlashRemoting('http://localhost/flashservices/gateway')







//Set the onLoad handler for when the flash gets the server response



fr.onLoad = function(obj){

//I'm expecting a query, so use the "toQuery" function

	var myQuery = this.toQuery(obj)

}

//Call the method on the remoting cfc (relative to the gateway url)

fr.load('com.cfcs.testing.getEmails', array)

trace(myQuery);





The cfc


<cfcomponent>

	<cffunction name="getResults" access="remote" returntype="query">

	  <cfargument name="getEmails" type="string" required="yes">

	    <cfquery name="getEmails" datasource="johnbarrett">

            SELECT *

            FROM testing

        </cfquery>

	    <cfreturn getEmails>

    </cffunction>

</cfcomponent>



I get an “undefined error” 🙁

Remoting Database Troubles

I have been stuggling with getting remoting working for a database result in AS 3 and ColdFusion. I am hoping that somebody can help me out with this.


import flash.net.*;

var gateway:NetConnection = new NetConnection();

var responder:Responder=new Responder(onResult,onFault);



// name the default cf test server on this machine

gateway.connect("http://localhost/flashservices/gateway/");



// name of the cfc and the function

gateway.call("com.cfcs.names.getnames", responder);



/*without the for loop in onResult (trace window [Object][Object])

with the foor loop nothing is traceed, but no errors

*/

function onResult(responds:Object):void {

	for(var i=0; i<responds; i++){

		trace(responds[i].toString());

	}

}



function onFault(responds:Object):void {

	//loop over the fault structure

	for (var i:String in responds) {

		trace( i + ":" + responds[i] );

	}

}

The cfc


 <cfcomponent>

        <cffunction name="getNames" acces="remote" returntype="query" output="yes">

                <cfquery datasource="johnny_flash" name="allNames">

                    SELECT Names, Comments

                    FROM Titles

                </cfquery>

            <cfreturn allNames>

        </cffunction>

    </cfcomponent>