Simone
02/21/2022, 3:02 PM<cffunction name="OnRequest">
<cfinclude template="custom.cfm">
</cffunction>
custom.cfm
<cffunction name="convert" returntype="numeric">
<cfargument name="argText">
<cf_calculate data="#argText#" key="500">
<cfreturn Val(calculate.value)>
</cffunction>
all i am getting is an empty Page, if i exclude the function onrequest, i get a page but it starts throwing errorsDavid Buck
02/21/2022, 7:25 PMOnRequest
method in your application.cfc, ColdFusion won't automatically process requested cfm pages. That's why you're getting a blank page. You have to explicitly cfinclude
requested pages in the OnRequest
method. See documentation.Simone
02/21/2022, 7:47 PMDavid Buck
02/21/2022, 7:55 PMSimone
02/21/2022, 7:57 PM<cffunction name="onRequest" returnType="void">
<cfargument name="targetPage" type="String" required=true/>
<cfinclude template="#Arguments.targetPage#">
</cffunction>
<!--- Alternate/cycle through the 3 accounts based on the minute. --->
<cfif Second(Now()) MOD 3 EQ 0>
<cfset Request.APIKey = "1">
<cfelseif Second(Now()) MOD 3 EQ 1>
<cfset Request.APIKey = "2">
<cfelse>
<cfset Request.APIKey = "3">
</cfif>
how should i handle this in my Application.cfc, should i create a function and just use the above technique and ignore onRequest method or should i create an included page and call that included page in onRequest MethodDavid Buck
02/21/2022, 8:56 PMOnRequest
is that it prevents you from using remote access cfc methods. If your app doesn't currently have any such methods, and you're sure it never will, then maybe it's okay to use OnRequest
(you would need to put the above code before the target page include). If you want to be able to have remote cfc methods, then use OnRequestStart
instead. It doesn't require the target page include.cfvonner
02/22/2022, 5:35 PMonRequest
is not called for remote CFC request, there is a corresponding onCFCRequest
method just for that purpose: https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/oncfcrequest.htmlonRequest
and still handle remote CFC requests (if you also add a onCFCRequest
function to your application.cfc).