Description
Runs at the end of a request, after all other CFML code.
Syntax
<cffunction name="onRequestEnd" returnType="void"> |
See also
onRequestStart, onRequest, Method summary, Managing requests in Application.cfc in Defining the application and its event handlers in Application.cfc in the Developing ColdFusion Applications
Parameters
ColdFusion passes the following parameters to the method:
Parameter |
Description |
---|---|
targetPage |
Path from the web root to the requested page. |
Returns
This method does not return a value; do not use the cfreturn tag.
Usage
This method has the same purpose as the onRequestEnd.cfm page. (You cannot use an onRequestEnd.cfm page if you have an Application.cfc file for your application.) This method runs before the request terminates; therefore, it can access the page context, and can generate output.This method can be useful for gathering performance metrics, or for displaying dynamic footer information.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 the Application.cfc file does not have an onRequest method.If you call this method explicitly, ColdFusion does not end the request, but does execute the method code.
Note: When using cfabort, cflocation, or cfcontent tags, the OnAbort method is invoked instead on OnRequestEnd.
Example
The following example displays one of two footer pages depending on whether the user has logged in:The onRequestEnd method in Application.cfc contains the following code:
<cffunction name="onRequestEnd"> |
A simple authuserfooter.cfm page consists of the following code:
<cfoutput> |
A simple noauthuserfooter.cfm page consists of the following code:
<cfoutput> |
To test this example, implement code for logging in a user, or try the example with and without the following line in the onRequestStart Application.cfc method:
<cfloginuser name="Robert Smith" password="secret" roles="customer"> |