Results 1 to 2 of 2
  1. #1
    Abina's Avatar
    Abina is offline Master
    Join Date
    Dec 2009
    Location
    United States
    Posts
    1,073
    Thanks
    1
    Thanked 6 Times in 4 Posts
    Feedback Score
    0

    Default 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>

  2. #2
    numberone's Avatar
    numberone is offline Senior
    Join Date
    Jan 2010
    Posts
    623
    Thanks
    0
    Thanked 1 Time in 1 Post
    Feedback Score
    0

    Default

    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 />

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Partners: BOSTON WEB DEVELOPER, LLC   |   WEBCOSMO CLASSIFIEDS