Adobe COLDFUSION 9 Manual page 127

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

122
DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
/**
* Simple Component.
*/
component {
/**
* Simple function.
*/
public void function foo() {
WriteOutput("Method foo() called<br>");
}
}
When you define a component entirely in CFScript, you do not have to use a
tag on the page. In this case,
cfscript
the component keyword can be preceded only by comments (including metadata assignments) and import operators.
Adobe recommends this format as a best practice. You specify component properties as follows:
/**
/*@default defaultValue
* @attrib1Name attrib1Value
* ...
*/
property [type]propName;
If the type precedes the property name, you do not need to use the "type" keyword, only the name of the specific type.
In either format, you must set the name attribute value. All other property attributes, such as type, are optional. As
with cfproperty tags, place the property operators at the top of the component definition, immediately following the
opening brace.
The syntax to define a function is similar to the component definition:
/**
*Comment text, treated as a hint.
*Set metadata, including, optionally, attributes, in the last entries
*in the comment block, as follows:
*@metadataName metadataValue
...
*/
access returnType function functionName(arg1Type arg1Name="defaultValue1"
arg1Attribute="attributeValue...,arg2Type
arg2Name="defaultValue2" arg2Attribute="attributeValue...,...)
functionAttributeName="attributeValue" ... {
body contents
}
You specify all function arguments, including the argument type, default value, and attributes in the function
definition.
The following example shows a function definition:
/**
* @hint="This function displays its name and parameter."
*/
public void function foo(String n1=10)
description="does nothing" hint="overrides hint" (
WriteOutput("Method foo() called<br> Parameter value is " & n1);
}
Specifying the
keyword makes the argument mandatory. If the
keyword is not present then the
required
required
argument becomes optional.
Last updated 8/5/2010

Advertisement

Table of Contents
loading

Table of Contents