Adobe COLDFUSION 9 Manual page 620

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
2
Modify getData.cfm so that the code appears as follows:
<cfparam name="pagesize" default="10">
<cfif IsDefined("Flash.Params")>
<cfset pagesize = Flash.Params[1]>
</cfif>
<cfquery name="myQuery" datasource="cfdocexamples">
SELECT *
FROM tblParks
</cfquery>
<cfset Flash.Pagesize = pagesize>
<cfset Flash.Result = myQuery>
In this example, if a single parameter is passed from the SWF application, the
of the
Flash.Params[1]
the database. After the querying, the
query results are assigned to the
3
Save the file.
When you assign a value to the
certain number of records, the record set becomes pageable and returns the number of records specified in the
variable. For example, the following code calls the
Flash.Pagesize
the first parameter to request a page size of 5:
import mx.remoting.*;
import mx.services.Log;
import mx.rpc.*;
// Connect to helloExamples service and create the CFMService service object
var CFMService:Service = new Service(
"http://localhost/flashservices/gateway",
null,
"helloExamples",
null,
null );
// Call the service getData() method
var pc:PendingCall = CFMService.getData(5);
// Tell the service what methods handle result and fault conditions
pc.responder = new RelayResponder( this, "getData_Result", "getData_Fault" );
function getData_Result(re:ResultEvent)
{
// Display successful result
DataGlue.bindFormatStrings(employeeData, re.result, "#PARKNAME#, #CITY#, #STATE#");
}
function getData_Fault(fe:FaultEvent)
{
// Display fault returned from service
trace("Error description from server: " + fe.fault.description);
}
In this example,
employeeData
PARKNAME, CITY, and STATE in the
ActionScript class assumes the task of fetching records. In this case, the list box requests more records as the user
scrolls the list box.
You can configure the client-side RecordSet object to fetch records in various ways using the
RecordSet.setDeliveryMode
variable; otherwise, the value of the variable is the default, 10. Next, a statement queries
variable is assigned to the
pagesize
variable, which is returned to the SWF application.
Flash.Result
variable, you are specifying that if the record set has more than a
Flash.Pagesize
is a Flash list box. The result handler,
list box. After the initial delivery of records, the RecordSet
employeeData
ActionScript function.
Last updated 8/5/2010
variable is set to the value
pagesize
variable. Finally, the
Flash.Pagesize
function of the CFMService and uses
getData()
displays the columns
getData_Result,
615

Advertisement

Table of Contents
loading

Table of Contents