Skip to main content
September 23, 2009
Question

Application.cfc migration problems

  • September 23, 2009
  • 1 reply
  • 550 views

I need help in converting application.cfm to application.cfc. I have
few functions defined in my current application.cfm, out of which few
are called within application.cfm only.

One of the function I have in my application.cfm is like as below:

  <cffunction name="loadAppCFC" access="public" displayname="Load CFC
module" hint="Load CFCs into the application scope">
      <cfargument name="ObjectName" REQUIRED="Yes"
TYPE="variableName">
      <cfargument name="LocalName" type="variableName"
default="#Arguments.ObjectName#">
      <cfargument name="Reload" type="string" default="n">

      <cfif Arguments.Reload eq "y" OR NOT IsDefined
("Application.Obj.#Arguments.ObjectName#") OR ISDefined
("Application.CFCReload.#Arguments.ObjectName#")>
           <CFTRACE text="Reloading cfc object #Arguments.ObjectName#
- #ISDefined('Application.CFCReload.#Arguments.ObjectName#')#">
           <cflock timeout="5" throwontimeout="Yes"
name="#Arguments.ObjectName#" type="EXCLUSIVE">
               <cfobject name="Application.Obj.#Arguments.LocalName#"
component="\CMP\#Arguments.ObjectName#">
               <CFIF IsDefined("Application.CFCReload")>
                   <cfset StructDelete(Application.CFCReload,
Arguments.ObjectName, "True")>
               </CFIF>
           </cflock>
      </cfif>
      <cfset Variables[Arguments.LocalName] = evaluate
("Application.Obj.#Arguments.LocalName#")>
   </cffunction>

In my Application.cfm loadAppCFC is used  as below:

   <CFSET loadAppCFC("comUDF", "comUDF",
Application.ini.debug.ReloadObjects)>

**** comUDF is again a CFC file containg UDF's.

Now when I am converting the code to application.cfc I inlcuded
onApplicationStart, OnSessionStart and OnRequest events. I separated
all the udf's into one file (all_udf.cfm) and I am including them as
below:

<cffunction name="onRequest">
       <cfargument name="targetPage" type="string" required="yes">
       <cfinclude template="all_udf.cfm">
       <cfinclude template="#targetPage#">
</cffunction>

I also included that file under onApplicationStart as below:
<cffunction name="onApplicationStart" returntype="boolean">
<cfinclude template="all_udf.cfm">

But I am still getting the error as "COMUDF is undefined". Please see
if anyone can provide any pointers in this regard..


Thanks!
Sanjeev Singla

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    September 26, 2009
    I also included that file under onApplicationStart as below:
    <cffunction name="onApplicationStart" returntype="boolean">
    <cfinclude template="all_udf.cfm">

    I don't think that is necessary, given that you do the include at every request.

    I separated all the udf's into one file (all_udf.cfm) and I am including them as below:

    <cffunction name="onRequest">
           <cfargument name="targetPage" type="string" required="yes">
           <cfinclude template="all_udf.cfm">
           <cfinclude template="#targetPage#">
    </cffunction>

    Why then do you still need the CFC containing the methods? In any casy, that CFC invocation line looks like it should instead be

    <CFSET loadAppCFC(comUDF, comUDF, Application.ini.debug.ReloadObjects)>

    This means you have to define comUDF beforehand. Perhaps something like

    <cfset comUDF = createobject("component", "dotted.path.to.comUDF")>