Simone02/21/2022, 3:02 PM
<cffunction name="OnRequest"> <cfinclude template="custom.cfm"> </cffunction>
all i am getting is an empty Page, if i exclude the function onrequest, i get a page but it starts throwing errors
<cffunction name="convert" returntype="numeric"> <cfargument name="argText"> <cf_calculate data="#argText#" key="500"> <cfreturn Val(calculate.value)> </cffunction>
David Buck02/21/2022, 7:25 PM
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
requested pages in the
method. See documentation.
Simone02/21/2022, 7:47 PM
David Buck02/21/2022, 7:55 PM
Simone02/21/2022, 7:57 PM
<cffunction name="onRequest" returnType="void"> <cfargument name="targetPage" type="String" required=true/> <cfinclude template="#Arguments.targetPage#"> </cffunction>
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 Method
<!--- 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>
David Buck02/21/2022, 8:56 PM
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
(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
instead. It doesn't require the target page include.
cfvonner02/22/2022, 5:35 PM
is not called for remote CFC request, there is a corresponding
method just for that purpose: https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/oncfcrequest.html
and still handle remote CFC requests (if you also add a
function to your application.cfc).