Skip navigation
mega_L
Currently Being Moderated

application.cfc vs application.cfm

Nov 16, 2011 11:43 AM

My CF version is 8 but since I came to this company and inherrited the codes, it looks like previous programmer did not use much of CF8 features.

I started to take advantage of CF8 features including cfc. One thing that I notice is all the existing apps. are using application.cfm and none uses application.cfc

 

I have sort of a portal web application where under this app. there are a bunch of different applications

The portal application has application.cfm that is encrypted so whenever I create a new app, I created my own application.cfm each with a different name set on the cfapplication tag

So it sort of to look like this:

 

Portal app

  application.cfm (encrypted)

     application_1

       application.cfm

 

     application_2

      application.cfm

  

     application_3

       application.cfm

 

I want to experience the CF8 application.cfc and from what I read, if I use application.cfc I can't use application.cfm because application.cfc replacing application.cfm and OnrequestEnd.cfm

when application.cfc is present both application.cfm and OnrequestEnd.cfm are going to be ignored.

My concern is, when I start creating application.cfc on my sub application, will the application.cfc ignoring Portal's application.cfm (the encrypted application.cfm) eventhough it is

on a much higher up in the directory tree?

 

So can i do the following without messing up the whole application?

Portal app

  application.cfm (encrypted)

     application_1

       application.cfm

 

     application_2

      application.cfm

  

     application_3

       application.cfm

 

     application_4

       application.cfc  <<< (?)

 
Replies
  • Currently Being Moderated
    Nov 16, 2011 3:59 PM   in reply to mega_L

    What happened when you tried it?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 16, 2011 6:29 PM   in reply to mega_L

    when I start creating application.cfc on my sub application, will the application.cfc ignoring Portal's application.cfm (the encrypted application.cfm) eventhough it is on a much higher up in the directory tree?

     

    Yes. In that respect, it is no different than an Application.cfm file. CF starts searching within the directory of the requested script for the first Application.cfc it finds (or if none exists, Application.cfm). As soon as it finds one, CF processes it and stops searching. So it is not even aware of any application files higher up in the directory tree.  

     

    You can find more details about how CF processes application.cfc/cfm files in  the documentation.  The example at the bottom of the page describes an application structure very similar to yours.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 17, 2011 6:39 PM   in reply to mega_L

    Yes, that would make a difference.  I have never cfincluded an application.cfm file from another appplication file. So I am really not sure what the results would be.  I imagine there is no technical reason you could not do that inside one of the Application.cfc methods, but without knowing what the main file does it would be tough to know where to include it or even what the results would be.  What variables/scopes does it affect? Also, what do the sub folder's application files do other than including the one from the parent directory?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 18, 2011 1:11 PM   in reply to -==cfSearching==-

    Typically, if you are using your inner application.cfm file just for its built-in OnRequestStart() functionality and not actually defining a new application name, you can include other application.cfm files to your hearts content.  I'm assuming that application.cfc's work in a similar manner.

     

    BTW - not sure if you saw Ben Nadel's article on extended functionality in pre-packaged encrypted application.cfm files, but it seemed to be appropriate to your problem so I thought I would include it:

     

    http://www.bennadel.com/blog/1322-Extending-Encrypted-ColdFusion-Appli cation-cfm-Functionality.htm

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 18, 2011 1:21 PM   in reply to insuractive

    You might be able to get it working if you leave off the NAME property of the application.cfc file (not sure if CF will throw an validation error because of that though).  Because you're not sure exactly what's in your original application.cfm, you may want to consider testing to see if you can include it by creating a blank application.cfm in the directory you are testing and trying to include your site's top application.cfm from there.  If it works, you know that its not the directory path that's an issue.  If it doesn't work, there may be some code in the top-level application.cfm that requires that it executes in a specific directory (though this is probably unlikely due to the nature of how application.cfm files are executed by CF).

     

    I think they may even be tools that will allow you to decrypt your template, provided that you have legal permission (EULA, DCMA, etc) to actually do that.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2011 5:40 AM   in reply to mega_L

    mega_L wrote:

     

    Would it matter if I created application.CFC on my subfolder application and then include the application.CFM from the main app. using cfinclude (see below)

    The reason I'm asking is, I'm pretty sure some variables are set in the Main's application.cfm and also some java codes are written in there. All of them are encrypted. I'm afraid in order for my new app to work properly I may need the main application.cfm. So it'll be prefect if I can include the Application.cfm from the main app in my new application.cfc

     

    I can't test it in my local machine. When I tried it I got a bunch of java errors.

     

     

    This is my application.cfc:

     

    <cfinclude template="/Application.cfm">

     

    That would in fact be my suggestion. Include Application.cfm via the onRequestStart event of Application.cfc (note capital A). Here follows an example

     

    <cfcomponent displayname="CFTests Application file">

        <cfscript>

            this.name = "bkbk_app";

            this.applicationTimeout = "#createTimespan(1,0,0,0)#";

            this.loginStorage = "session";

            this.sessionManagement = "true";

            this.sessionTimeout = "#createTimeSpan(0,0,20,0)#";

            this.setClientCookies = "yes";

            this.scriptProtect = "yes";

        </cfscript>

     

    <cffunction name="onApplicationStart" returntype="boolean">

    <cfreturn true>

    </cffunction>

     

    <cffunction name="onSessionStart">

    </cffunction>

     

    <cffunction name="onRequestStart">

    <cfargument name = "targetPage" type="String" required="yes">

        <cfinclude  template="/Application.cfm">

    </cffunction>

     

    <cffunction name="onRequestEnd">

    <cfargument type="String" name = "targetTemplate" required="yes">

    </cffunction>

     

    <cffunction name="onSessionEnd">

    <cfargument name = "SessionScope" required="yes">

    <cfargument name = "AppScope" required="yes">

        <cflog file="#This.Name#" type="Information" text="Session: #arguments.SessionScope.sessionid# ended">

    </cffunction>

     

    <cffunction name="onApplicationEnd">

    <cfargument name="ApplicationScope" required="yes">  

        <cflog file="#This.Name#" type="Information" text="Application #ApplicationScope.applicationname# ended">

    </cffunction>

    </cfcomponent>

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2011 11:39 AM   in reply to insuractive

    Because you're not sure exactly what's in your original application.cfm, you may want to consider testing to see if you can include it by creating a blank application.cfm in the directory you are testing and trying to include your site's top application.cfm from there.

    Yeah, I did not think there would be any technical problem with including a file.  But without knowing what it does, or what scopes it affects, I could not say definitively where it belongs. OnRequestStart is certainly the most logicial guess.  But again .. knowing so little about it, I think testing it out would be a wise idea.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points