| Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > Using UDFs effectively > Specifying the scope of a function Using the Request scope |
|
|
|
|
||
You can effectively manage functions that are used in application pages and custom tags by doing the following:
cfinclude tag to include the function definition page on the application page, but do not include it on any custom tag pages.This way you only need to include the functions once per request and they are available throughout the life of the request. For example, create a myFuncs.cfm page that defines your functions and assigns them to the Request scope using syntax such as the following:
function MyFunc1(Argument1, Argument2)
{ Function definition goes here }
Request.MyFunc1 = MyFunc1
The application page includes the myFuncs.cfm page:
<cfinclude template="myfuncs.cfm">
The application page and all custom tags (and nested custom tags) call the functions as follows:
Request.MyFunc1(Value1, Value2)
|
|
||
| Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > Using UDFs effectively > Specifying the scope of a function Using the Request scope |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.