User Guide
onRequestStart 957
onRequestStart
Description
Runs when a request starts.
Syntax
<cffunction name="onRequestStart" returnType="boolean">
<cfargument type="String" name="targetPage" required=true/>
...
<cfreturn Boolean>
</cffunction>
See also
onRequest
, onRequestEnd, Method summary, “Managing requests in Application.cfc” in
ColdFusion MX Developer’s Guide
Parameters
ColdFusion MX passes the following parameters to the method:
Returns
A Boolean value. Return False to prevent ColdFusion from processing the request. You do not
need to explicitly return a True value if you omit the
cffunction tag returntype attribute.
Usage
This method runs at the beginning of the request. It is useful for user authorization (login
handling), and for request-specific variable initialization, such as gathering performance statistics.
If this method throws an exception (for example, if it uses the
cfthrow tag), ColdFusion handles
the error and does not process the request further.
If you call this method explicitly, ColdFusion does not start a request, but does execute the
method code.
This method can access the requested page’s Variables scope only if the Application.cfc file
includes an
onRequest method that calls the page. You can use Request scope variables to share
data with the requested page even if Application.cfc does not have an
onRequest method.
Example
This example uses the authentication code generated by the ColdFusion MX Dreamweaver Login
wizard to ensure that the user is logged in. For Beta 2, the wizard generates code that is
appropriate for Application.cfm only. To use this code with the Application.CFC, delete the
generated Application.CFM
<cffunction name="onRequestStart">
<cfargument name="requestname" required=true/>
<!--- Authentication code, generated by the Dreamweaver Login wizard.
<cfinclude template="mm_wizard_application_include.cfm">
Parameters Description
targetPage Path from the web root to the requested page.