I'm trying to pass on a value from a cfselect to a CFC through actionscript. I
don't know if it's the right to accomplish what I'm trying to do. It feels like
the solution is so obvious but it's eluding me =(
When running the code it's telling me that the variable suppose to be passed
to the CFC doesn't reach it.
Any help would be greatly appreciated.
The CFC
<cfcomponent output="false">
<cffunction name="getReports" access="remote" returntype="query"
output="false">
<cfset var p_PortalReport_Get_RS1 = ''>
<!--- SP fetching data --->
<cfstoredproc datasource="#Application.DSN#" procedure="p_PortalReport_Get">
<cfprocparam type="in" cfsqltype="cf_sql_integer" value="1">
<cfprocresult name="p_PortalReport_Get_RS1">
</cfstoredproc>
<cfquery name="ReportNameQry" dbtype="query">
select reportid, report
from p_PortalReport_Get_RS1
</cfquery>
<!--- Retuning the data --->
<cfreturn ReportNameQry>
</cffunction>
<cffunction name="getDescription" access="remote" output="false">
<!--- Required arguments from caller --->
<cfargument name="reportid" required="yes" type="numeric">
<cfset var p_PortalReport_Get_RS1 = ''>
<!--- SP fetching data --->
<cfstoredproc datasource="#Application.DSN#" procedure="p_PortalReport_Get">
<cfprocparam type="in" cfsqltype="cf_sql_integer" value="1">
<cfprocresult name="p_PortalReport_Get_RS1">
</cfstoredproc>
<cfquery name="ReportDescription" dbtype="query">
select description
from p_PortalReport_Get_RS1
where reportid = #Arguments.reportid#
</cfquery>
<cfoutput>
<cfset descriptionString = "#ReportDescription.description#">
</cfoutput>
<!--- Retuning the data --->
<cfreturn descriptionString>
</cffunction>
</cfcomponent>
The cfm page
<cfform format="flash" skin="halosilver" height="480" width="300"
onload="getData()" >
<cfformitem type="script">
public function getData():Void{
<cfoutput>
//create connection
var connection:mx.remoting.Connection =
mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashser
vices/gateway/");
//declare service
var myService:mx.remoting.NetServiceProxy;
</cfoutput>
//make an object that will handle the response
var responseHandler = {};
//put the controls in scope to avoid calling _root
var reportName = reportName;
//function that receives the response
responseHandler.onResult = function( results: Object ):Void {
//when results are back, we show the text received
reportName.labelField = "report";
reportName.dataProvider = results;
}
//function that receives any error that may have occurred during the
call
responseHandler.onStatus = function( stat: Object ):Void {
//if there is any error, show an alert
alert("Error while calling cfc:" + stat.description);
}
//get service. First parameter is path to component and
//the second it's the object that will handle the response
myService = connection.getService("reports.reportsComponent",
responseHandler );
//make call
myService.getReports();
}
public function getDescription():Void{
<cfoutput>
//create connection
var connection:mx.remoting.Connection =
mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashser
vices/gateway/");
//declare service
var myService:mx.remoting.NetServiceProxy;
</cfoutput>
//make an object that will handle the response
var responseHandler = {};
//put the controls in scope to avoid calling _root
var Description = Description;
var reportName = reportName;
//function that receives the response
responseHandler.onResult = function( results: Object ):Void {
//when results are back, we show the text received
Description.text = results;
}
//function that receives any error that may have occurred during the
call
responseHandler.onStatus = function( stat: Object ):Void {
//if there is any error, show an alert
alert("Error while calling cfc:" + stat.description);
}
var input = reportName.selectedItem.data;
//get service. First parameter is path to component and
//the second it's the object that will handle the response
myService = connection.getService("reports.reportsComponent",
responseHandler );
//make call
myService.getDescription();
}
</cfformitem>
<cfformgroup type="page">
<cfselect name="reportName" id="reportName" label="Report"
onChange="getDescription()">
</cfselect>
<cfformitem type="spacer" height="15" />
<cftextarea name="Description" label="Description" /> <!---
{testSelect.selectedItem.data} --->
<cfformitem type="spacer" height="25" />
<cfinput type="submit" name="submit" value="Submit">
</cfformgroup>
</cfform>