• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Application.cfc, OnRequestStart, CFInclude

Engaged ,
Jun 07, 2006 Jun 07, 2006

Copy link to clipboard

Copied

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???

TOPICS
Advanced techniques

Views

304

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation