Whatever message this page gives is out now! Go check it out!
<cfinterface
displayName = "descriptive name"
extends = "interfaceName1[,interfaceName2]..."
Hint = "hint text">
<cffunction ...>
<cfargument ... >
<cfargument ... >
...
</cffunction>
<cffunction ...>
...
</cffunction>
...
</cfinterface>| Attribute | Req/Opt | Default | Description |
displayName | Optional | A value to be displayed when using introspection to show a descriptive name for the interface. | |
extends | Optional | A comma-delimited list of one or more interfaces that this interface extends. Any CFC that implements an interface must also implement all the functions in the interfaces specified by this property. If an interface extends another interface, and the child interface specifies a function with the same name as one in the parent interface, both functions must have the same attributes; otherwise ColdFusion generates an error. | |
hint | Optional | Text to be displayed when using introspection to show information about the interface. The hint attribute value follows the syntax line in the function description. |
<cfinterface extends="IBasicInterface">
<cffunction name="hello" description="Should print a greeting containing the input
argument or 'world'.">
<cfargument name="whom" type="string" default="world">
</cffunction>
<cffunction name="calculateTwo" returnType="numeric" output="no"
description="calculates a result using two numbers and returns the result">
<cfargument name="first" type="numeric" required="yes"/>
<cfargument name="second" type="numeric" required="no" default="0"/>
</cffunction>
<cffunction name="disclaimer"/>
</cfinterface>| Attribute | Interface requirements | Implementation requirements |
cffunction | ||
access | Optional; only public is allowed | Optional; can be public or remote. |
description | Optional | Can differ from value in interface. |
displayName | Optional | Can differ from value in interface. |
hint | Optional | Can differ from value in interface. |
name | Required | Must be identical to value in interface. |
output | Optional | Need not be identical to the value in the interface. Even if you omit the attribute in the interface, you can use it in the implementation. Similarly, you can use the attribute in the interface and omit it in the implementation. |
returnType | Optional | Must be identical to value in interface; however, an omitted type option and an option value of any are equivalent and ColdFusion treats them as a match. |
roles | Not allowed | Can be any valid value. |
cfargument | ||
default | Optional | Must be identical to value in interface. If you omit this attribute in the interface, you can specify any value in the implementation. |
displayName | Optional | Can differ from value in interface |
hint | Optional | Can differ from value in interface |
name | Required | Must be identical to value in interface. |
required | Optional | If the interface specifies yes, this attribute must also specify yes. If the interface specifies no or omits this attribute, you can specify no or omit the attribute. |
type | Optional | Must be identical to value in interface; however, an omitted type option and an option value of any are equivalent and ColdFusion treats them as a match. |
<cfinterface>
<cffunction name = add returntype = "numeric" output = "no"
description = "Add two values">
<cfargument name = "first" type="numeric" required = "no" default ="0">
<cfargument name = "second" type = "numeric" required = "no" default = "0">
</cffunction>
<cffunction name = subtract returntype = "numeric" output = "no"
description = "Subtract two values">
<cfargument name = "first" type = "numeric" required = "no" default = "0">
<cfargument name ="second" type = "numeric" required = "no" default = "0">
</cffunction>
<cffunction name = multiply returntype = "numeric" output = "no"
description = "Multiply two values">
<cfargument name = "first" type = "numeric" required = "no" default = "0">
<cfargument name = "second" type = "numeric" required = "no" default = "0">
</cffunction>
<cffunction name = divide returntype = "numeric" output = "no"
description = "Divide two values">
<cfargument name = "first" type = "numeric" required = "no" default="0">
<cfargument name = "second" type="numeric" required = "no" default="1">
</cffunction>
</cfinterface><cfcomponent implements = "IBasicMath" >
<cffunction name = add returntype = "numeric" output = "no"
description = "Add two values">
<cfargument name = "first" type = "numeric" required = "no" default = "0">
<cfargument name = "second" type = "numeric" required = "no" default = "0">
<cfreturn Round(first + second)>
</cffunction>
<cffunction name = subtract returntype = "numeric" output = "no"
description = "Subtract two values">
<cfargument name = "first" type = "numeric" required = "no" default = "0">
<cfargument name = "second" type = "numeric" required = "no" default = "0">
<cfreturn Round(first - second)>
</cffunction>
<cffunction name = multiply returntype = "numeric" output = "no"
description = "Multiply two values">
<cfargument name = "first" type = "numeric" required = "no" default = "0">
<cfargument name = "second" type = "numeric" required = "no" default = "0">
<cfreturn Round(first * second)>
</cffunction>
<cffunction name = divide returntype = "numeric" output = "no"
description = "Divide two values">
<cfargument name = "first" type = "numeric" required = "no" default = "0">
<cfargument name = "second" type = "numeric" required = "no" default = "1">
<cfreturn Round(first / second)>
</cffunction>
</cfcomponent><cfscript>
arguments = StructNew();
arguments.first = pi();
arguments.second = "2.718281828459045235360287471352";
</cfscript>
<cfobject name = "iMathObj" component = "integerMath">
<cfoutput>
<h3>Function Arguments</h3>
argument 1: #arguments.first#<br>
argument 2: #arguments.second#<br>
<h3>Addition</h3>
#iMathObj.add(argumentCollection = arguments)#
<h3>Subtraction</h3>
#iMathObj.subtract(argumentCollection = arguments)#
<h3>Multiplication</h3>
#iMathObj.multiply(argumentCollection = arguments)#
<h3>Division</h3>
#iMathObj.divide(argumentCollection = arguments)#
</cfoutput>