Results 1 to 2 of 2
-
01-09-2010, 03:05 PM #1
Properly passing arguments from an invoke to a component
OK, I am confused... error says:
Code:<body> <cfset databaseSource = "test"> <!--- defining the datasource (database name) ---> <cfset sourceTable = "testnavigation"> <!--- defining the table we will be getting the data from ---> <cfinvoke component="cfdocs.Recursive Navigation.cfcomponents.navigation" method="MakeBreadCrumb" returnvariable="MakeBreadCrumbRet"> <cfinvokeargument name="id" value="#URL.item#"/> <cfinvokeargument name="cnt" value="1"/> <cfinvokeargument name="dataSource" value="#databaseSource#"/> <cfinvokeargument name="table" value="#sourceTable#"/> </cfinvoke> </body>
-
02-02-2010, 11:38 AM #2
1. var scoping is very important
example:
<cffunction name="myMethod" returnType="void">
<cfset var temp />
<cfset var myCounter = 1 />
.....some code that uses temp and myCounter....
</cffunction>
I prefer this method:
<cffunction name="myMethod" returnType="void">
<cfset var local = {} />
<cfset local.myQueryResult />
<cfset local.myMathsRrsult />
.....some code that uses variables local to the method ....
</cffunction>
All variables are then protected from modification outside of the function and your not going to accidentally change variables that are not local to the function. The local scope exists implicitly in ColdFusion 9 so I recommend that way.
1 and 3 are related you should always be using <cfqueryparam />




Reply With Quote

