Skip to main content
BreakawayPaul
Inspiring
June 26, 2014
Answered

What's wrong with my Application.cfc file

  • June 26, 2014
  • 1 reply
  • 453 views

I've decided to convert an old app from using Application.cfm to Application.cfc, mainly because I want to use onRequestStart and the like, and I can't get them to initialize in Application.cfm.

But for some reason, this Application.cfc file causes my pages to come up blank.  I can't for the life of me figure out why, since it's copied from an app that works perfectly fine.

<cfcomponent>

    <cfset this.name = "myapp">

    <cfset this.sessionManagement = true>

    <cfset this.sessionTimeout = CreateTimeSpan(0,2,0,0)>

    <cfset this.loginStorage="session">

    <cfset this.scriptProtect = true>

    <cfset this.setclientcookies = false>

    <cffunction name="onApplicationStart">

        <cfset application.dsource = "mydsn">

        <cfset application.appid = "123456">

        <cfset application.appname = "myappname">

    </cffunction>   

 

    <cffunction name="onSessionStart">

        <cfparam name="session.trackingno" default="0">

        <cfparam name="session.emailaddr" default="">

        <cfparam name="session.newitem" default="1">

        <cfparam name="session.authserver" default="">

        <cfparam name="session.id" default="">

        <cfparam name="session.rights" default="">

        <cfparam name="session.userid" default="">

        <cfparam name="session.sauth" default="">

        <cfparam name="session.creds" default="">

    </cffunction>

 

      <cffunction name="onRequest" output="true">   

        <cfinclude template="/planning/application.cfm">   

        <cfinclude template="/planning/tpea/2015/validate.cfm">

      </cffunction>

   

</cfcomponent>

What have I done wrong?

    This topic has been closed for replies.
    Correct answer Carl Von Stetten

    What is in the two templates you are including inside your onRequest() function?  Do they actually output any content?

    You don't have the actual requested page being included.  You need to add an argument to the top of the function to receive the requested page:

    <cfargument name="TargetPage" type="string" required="true">

    Then you need to add another <cfinclude> to include that page:

    <cfinclude template="#arguments.TargetPage#" />

    You'll have to figure out if that include should come before or after your existing includes.

    -Carl V.

    1 reply

    Carl Von Stetten
    Carl Von StettenCorrect answer
    Legend
    June 26, 2014

    What is in the two templates you are including inside your onRequest() function?  Do they actually output any content?

    You don't have the actual requested page being included.  You need to add an argument to the top of the function to receive the requested page:

    <cfargument name="TargetPage" type="string" required="true">

    Then you need to add another <cfinclude> to include that page:

    <cfinclude template="#arguments.TargetPage#" />

    You'll have to figure out if that include should come before or after your existing includes.

    -Carl V.

    BreakawayPaul
    Inspiring
    June 26, 2014

    oh my !!!

    You know, you'd think I'd notice something that simple!!!  Oddly, the app I copied the Application.cfc file from doesn't have that and still works (it's another ancient thing I inherited and converted).  Very odd!

    Anyway, as you can imagine, it works!  Thanks Carl!