
615
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
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
pagesize
variable is set to the value
of the
Flash.Params[1]
variable; otherwise, the value of the variable is the default, 10. Next, a statement queries
the database. After the querying, the
pagesize
variable is assigned to the
Flash.Pagesize
variable. Finally, the
query results are assigned to the
Flash.Result
variable, which is returned to the SWF application.
3
Save the file.
When you assign a value to the
Flash.Pagesize
variable, you are specifying that if the record set has more than a
certain number of records, the record set becomes pageable and returns the number of records specified in the
Flash.Pagesize
variable. For example, the following code calls the
getData()
function of the CFMService and uses
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
is a Flash list box. The result handler,
getData_Result,
displays the columns
PARKNAME, CITY, and STATE in the
employeeData
list box. After the initial delivery of records, the RecordSet
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
ActionScript function.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...