2 Replies Latest reply on Feb 15, 2010 3:04 PM by BKBK

    debug cfc cfcomponent cfinvoke


      I am new to cfcomponent.  I am trying to convert some .cfm database pages (insert, delete, update, etc) into an oop DAO class.  But I am using the method of:

      A) code one function in .cfc, B) test by trial and error the function (Not debug), C) repeat.


      I based my code on Part 3:"Gateways and Datasources" section of   http://learn.objectorientedcoldfusion.org/wiki/Gateway .


      Known unsolvable facts: 1) Unfortunately, I am developing on Vista 64bit (using dreamweaver) and cannot local debug because code (hundreds of .cfm pages) was written for microsoft access database. 2) I have to use "production server" for trial and error on remote host (readyhosting.com) 3) Production server is running Coldfusion 7 and do not have access to coldfusion administrator. 4) Do not have money in budget to downgrade vista 64 bit computer.


      SUMMARY of PROBLEM: my .cfc is persistent.  How do I stop .cfc from being persistent for debugging? Is there a deleteObject() or a workaround.


      Details of problem:

      I have two pages. 1) PeopleType_test.cfm and 2) PeopleType.cfc.






      <cfif not isDefined("peopleObj")>
      <cfif isDefined("Session.peopleObjVar")>
        <cflock timeout=30 scope="Session" type="Exclusive">
         <cfset peopleObj= Session.peopleObjVar>
            <cfinvoke   component="PeopleTypeVer5"   method="init" returnVariable="peopleObj">
             <!---cfset peopleObj= createObject("component","PeopleTypeVer5") --->
            <cflock timeout=30 scope="Session" type="Exclusive">
              <cfset Session.peopleObjVar= peopleObj>

      ... get data from user using form ...

      ... store data in peopleObj, using

      <cfinvoke component="#peopleObj#" method="FindQryPeopleIdBy__names_gIdVer5">
            <cfinvokeargument name="a_storeFlag" value="yes"/>
            <cfinvokeargument name="a_firstname"  value="#form.firstname#"/>
            <cfinvokeargument name="a_lastname"   value="#form.lastname#"/>
            <cfinvokeargument name="a_grantee_id" value="#form.grantee_id#"/>
            <cfinvokeargument name="a_maxFlag" value="yes"/>







          <cffunction name="FindQryPeopleIdBy__names_gIdVer5" output="false" returntype="query" >
              <cfargument name="a_storeFlag"  required="false" type="boolean" default="no">
              <cfargument name="a_firstname"  required="false" type="string">
              <cfargument name="a_lastname"   required="false" type="string">
              <cfargument name="a_grantee_id" required="false" type="numeric">
              <cfargument name="a_maxFlag"    required="false" type="boolean" default="no">
              <cfset filter = StructNew()>
              <cfif structKeyExists(arguments,"a_storeFlag") and arguments.a_storeFlag>
               <cfif structKeyExists(arguments,"a_firstname")>  <cfset variables.instance.p_firstname= arguments.a_firstname></cfif>
               <cfif structKeyExists(arguments,"a_lastname")>   <cfset variables.instance.p_lastname=  arguments.a_lastname></cfif>       
               <cfif structKeyExists(arguments,"a_grantee_id")> <cfset variables.instance.p_grantee_id=arguments.a_grantee_id></cfif>
              <cfset StructInsert(filter,"ff_firstname",
          , "#arguments.a_firstname#"
          , "#variables.instance.p_firstname#"))
        <cfset StructInsert(filter,"ff_lastname",
         iif(structKeyExists(arguments,"a_lastname"),   "#arguments.a_lastname#",  "#variables.instance.p_lastname#"))>
              <cfset StructInsert(filter,"ff_grantee_id",
             iif(structKeyExists(arguments,"a_grantee_id"), "#arguments.a_grantee_id#","#variables.instance.p_grantee_id#"))>
              <cfset StructInsert(filter,"ff_maxFlag",
         iif(structKeyExists(arguments,"a_maxFlag"),    "#arguments.a_maxFlag#", "no")) >
              <cfset StructInsert(filter,"ff_storeFlag",
         iif(structKeyExists(arguments,"a_storeFlag"),  "#arguments.a_storeFlag#", "no")) >
              <cfreturn FindQry_PeopleId_using_filter(filter)>





      I am using Internet Explorer 8.0 and dreamweaver cs3 and Coldfusion 7 (on remote production server).  So here is what happens:

      A) In PeopleTypeVer5.cfc, I edit the code (to fix compiler errors / logic errors) in "FindQryPeopleIdBy__names_gIdVer4" function

      B) In both files, I change my "FindQryPeopleIdBy__names_gIdVer4" function name to "FindQryPeopleIdBy__names_gIdVer5"


      C) I rename PeopleTypeVer4.cfc to PeopleTypeVer5.cfc

      D) In PeopleType_test.cfm, I change TO <cfinvoke component="PeopleTypeVer5"...>


      E) I ftp both files to server

      F) I "refresh" PeopleType_test.cfm page in browser.  Cfinvoke still thinks it is using old PeopleTypeVer4.cfc, not the new PeopleTypeVer5.cfc -- it does NOT refresh page?  Even though I changed name?

      G) I originally tryied to just perform steps A, B, E,F (skip steps C,D) and it does not work.

      Q? How do I tell coldfusion to "expire" or force a reload of the new version of my PeopleTypeVer5.cfc component?

      Q? or Is there some kind of workaround?

      Q? or Is there some way to leverage a factory pattern to get around this problem?

      Q? or Is there some way at runtime (say in a form field) that I could enter in the name of the .cfc I want to "load" or use?




        • 1. Re: debug cfc cfcomponent cfinvoke
          Adam Cameron. Level 5

          Whilst you're debugging it, don't put it in the session scope.


          Or add an onRequestEnd() handler temporarily, and delete the peopleObjVar from the session scope at the end of each request, so it reloads each request.


          Editorial comment: I'm not sure you need to call the variable peopleObjVar.  It's obvious it's a variable.  What else would it be?




          • 2. Re: debug cfc cfcomponent cfinvoke
            BKBK Adobe Community Professional & MVP
            How do I tell coldfusion to "expire" or force a reload of the new version of my PeopleTypeVer5.cfc component?

            You could change the settings to prevent caching in the caching page in the Coldfusion Administrator. However, since you have no access to the Administrator, you could just change the name of the application in Application.cfc.