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

CFINCLUDE via OnRequestStart

Guest
Dec 05, 2008 Dec 05, 2008
I have a CFINCLUDE tag in my application.cfc file's onRequestStart method that includes a template of functions that I commonly use.

Unfortunately, when included via the application.cfc, the functions cannot be called. A simple "functionName()" between CFOUTPUT tags throws a "variable functionName is undefined" error.

If I use a CFINCLUDE tag in the page directly, everything works just fine. I would assume this is some sort of scoping issue, but I'm not sure what scope the function is going to when called via application.cfc. Either that or some other simple, obvious issue that I'm missing. Can anyone point out what I'm forgetting? Thanks!
TOPICS
Advanced techniques
410
Translate
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
Engaged ,
Dec 05, 2008 Dec 05, 2008
Things included in onRequestStart are in the scope of the CFC, not your document. You can always put your UDFs in the request scope. So for example, you udf.cfm could do:

request.udfs = structNew();
function foo() { return 1;}
request.udf.foo = foo;

Then to call your function you would use request.udf.foo().
Translate
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
LEGEND ,
Dec 05, 2008 Dec 05, 2008
LATEST
Why are you using cfoutput to call your function?
Translate
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