I can make this shorter than my earlier post: Does anyone know how to pass a
variable from a regular CFM template to a CFC component to create a dynamic
query? Any help is greatly appreciated. Thanks
derobinson - 09 Mar 2005 16:52 GMT
Use the CFinvoke tag to call a method in your CFC and send your variable as an argument to it. Here, this may help:
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p67.htm
Good luck!
Circulus - 10 Mar 2005 01:34 GMT
Thanks, Could you clarify your suggestion? Do you use CFInvoke inside the CFM
with a CFinvokeArgument to pass the variable 'ReqID', as follows: <cfinvoke
component='MyBillingData' method='ListByOrder' >
<cfinvokeargument name='ReqID' value='#ReqID#'> </cfinvoke>
Or use CFINVOKE inside the CFC?? I've seen it used both ways, and I'm unsure.
I'm running debug from my Application.cfm and I can see that the query inside
the CFC is receiving the correct variable, but isn't outputting data in Flash.
Thanks for your help!!
derobinson - 10 Mar 2005 20:12 GMT
Off the top of my head, what you have here looks correct (but I'd have to go
check the syntax to make absolutely sure). You'd put this in the CFM that calls
the CFC. You can also use CFinvoke from inside a CFC to call other methods in
the same CFC (usually private methods that are only available to that CFC and
nothing else) or I guess potentially other CFCs. The difference being where the
data is returned, back to teh CFM or back to a certain method in a CFC for
further use in that CFC.
Hope that makes sense!
Circulus - 11 Mar 2005 18:47 GMT
Thanks David for your help. The <cfinvoke in the CFM is connecting to the CFC
which runs the query and returns data to the CFM. I used <CFDUMP to confirm
this in the CFM. For some reason, the data isn't displaying in the embedded
Flash swf and I'm receiving an error message that the ReqID variable wasn't
passed in or if I have the <CFARGUMENT tag in the CFC, the error output in the
NetConnectionDebugger is that ReqID is required and wasn't passed in. Here's
the code in the CFC: <CFCOMPONENT hint='User db tools'> <CFFUNCTION
NAME='ListByOrder' HINT='Get mobiles' ACCESS='remote' RETURNTYPE='Array'>
<!---<CFARGUMENT NAME='ReqID' TYPE='string' required='Yes'>---> <cfset var
mobiles=''> <cfparam name='ReqID' default=''> <CFQUERY datasource='OTG'
NAME='mobiles'> SELECT * FROM tblShowMeDetail WHERE
DetailReqID='#ReqID#' </CFQUERY> <cfset convertedquery=convert(mobiles)>
<cfreturn convertedquery> </CFFUNCTION> </CFCOMPONENT> There's another
function above the query which converts the query data into an array before
returning the array of data to Flash or the <CFDump in the CFM. Am I missing
something obvious? Thanks