|
I have created a sample peice of code where the cfform type=flash uses the cfsavecontent to call a cfc and return information from a query.
We set up a cfsavecontent named callingCFC and use it when the cfform is submitted. the cfsave content calls the cfc stateResponder.cfc passing it the text entered from the form. The cfc queries the state table based o the information entered and then returns the information which is then returned to the display field.
stateResponder.cfcbbbb
------------------------------------------
<cfcomponent name="stateResponder" access="public" description="Responds to Flash load vars requests">
<cffunction name="getState"
output="true"
description="Returns the state that was passed"
access="remote" returntype="void">
<cfargument name="passedinfo" required="false" type="string" default=""/>
<cfinclude template = "../getdsninfo.cfm">
<cfquery datasource="#dsname#" name="getstatename" username="#dbusername#" password="#dbpassword#">
Select * from states
where state_id = '#passedinfo#'
</cfquery>
<cfoutput>&statename=#getstatename.state#</cfoutput>
</cffunction>
</cfcomponent>
index.cfm
------------------------------
<cfsavecontent variable="callingCFC">
var dataholder = this.createEmptyMovieClip('dataholder',4587);
dataholder.method = "getState";//the cfc method
dataholder.passedinfo = textEntered.text; //the parameter mask the component expects
dataholder.loadVariables ('stateResponder.cfc', 'POST');//note the component name with full path
var display = display;
var obj = {};
var checkData = function(obj)
{
if(dataholder.statename != undefined)
{
clearInterval(obj.id);
display.text = dataholder.statename;
dataholder.statename = undefined;
}
}
obj.id = setInterval(checkData, 100, obj);
</cfsavecontent>
<cfform name="myform" height="200" width="400" format="Flash" timeout="0" >
<cfformitem name="mesg" type="html"><p>Enter a state abbreviation and click "Get State". </p></cfformitem>
<cfformgroup type="hbox">
<cfformgroup type="vbox" id="displayHolder">
<cfinput type="text" name="textEntered" label="State initials" value="TX">
<cfinput type="text" name="display" disabled="true" style="borderStyle:none; fontWeight:bold; disabledColor:##000000" label="Result" />
</cfformgroup>
<cfformgroup type="vbox" width="120">
<cfinput type="Button" name="setFunction" width="104" value = "Get State" onclick="#callingCFC#" style="cornerRadius:0; borderThickness:1;">
</cfformgroup>
</cfformgroup>
</cfform>
|