1 Reply Latest reply on Jun 8, 2006 2:41 AM by BKBK

    Application.cfc, OnRequestStart, CFInclude

    KomputerMan.com Level 1
      O.K. I'll admit I am feeling a little stupid here but I just don't understand this. All I wanted to do was include my script library file using the OnRequestStart function within application.cfm. There isn't anything special in the _ScriptLib.cfm template. My Application.cfc file looks like this... (Only the pertinent portions are included)

      <CFFUNCTION NAME="onRequestStart" OUTPUT="Yes" RETURNTYPE="any">
      <CFINCLUDE TEMPLATE="_ScriptLib.cfm">
      ... (other CFSETS and junk like that)
      </CFFUNCTION >

      <CFFUNCTION NAME="onRequest">
      <CFARGUMENT NAME="targetTemplate" type="String" required="true" />
      <CFINCLUDE TEMPLATE="#arguments.targetTemplate#">
      </CFFUNCTION>

      My question is why do I need to add the CFArgument tag in the OnRequest function to include my scripts??? Why doesn't the CFInclude tag in OnRequestStart take care of it for me???

        • 1. Re: Application.cfc, OnRequestStart, CFInclude
          BKBK Adobe Community Professional & MVP
          My question is why do I need to add the CFArgument tag in the OnRequest function to include my scripts???
          You don't need to add the cfargument tag to onRequest to enable you to use cfinclude in OnRequestStart. In this case, the only musts are: if you implement the OnRequest method, then it must load the target-page through a cfargument tag and it must explicitly call the page through a cfinclude tag.

          That makes the Variables scope of the requested page (and its included pages!) available in OnRequestStart. If a variable is called x in the requested page, you may just call it x in OnRequestStart. If you hadn't included the cfargument and cfinclude tags in OnRequest, or if you didn't iimplement the OnRequest method at all, the only page variables you would have access to in OnRequestStart are those in Request scope.