Invoking Component Objects; Coding Guidelines; Calling Methods - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 19: Using CFOBJECT to Invoke Component Objects

Invoking Component Objects

The CFOBJECT tag is used to create an instance of the object and other ColdFusion
tags, such as CFSET and CFOUTPUT, are used to invoke properties (attributes), and
methods (operations) on the object. An object created by CFOBJECT or returned by
other objects is implicitly released at the end of the template execution.

Coding guidelines

The following coding practice is required (or recommended) when accessing the
object. Assume that the NAME attribute in the CFOBJECT tag specified the value "obj",
and that the object has a property called "Property", and methods called "Method1",
"Method2", and "Method3".
To set a property:
<CFSET obj.property = "somevalue">
To get a property:
<CFSET value = obj.property>
Note that parentheses are not used on the right side of the equation for property-gets.

Calling methods

Object methods usually take zero or more arguments. Arguments can be sent by value
([in] arguments) or by reference ([out] and [in,out]). Arguments sent by reference
usually have their value changed by the object. Some methods return values while
others may not.
Methods with no arguments:
<CFSET retVal = obj.Method1()>
Note that parentheses are required for methods with no arguments.
Methods with one or more arguments:
<CFSET x = 23>
<CFSET retVal = obj.Method1(x, "a string literal")>
This method accepts one integer argument, and one string argument.
Methods with reference arguments:
<CFSET x = 23>
<CFSET retVal = obj.Method2("x",
<CFOUTPUT> #x#</CFOUTPUT>
Note the use of double-quotes ("") to specify reference arguments. If the object
changes the value of "x", it will now contain a value other than 23.
"a string literal")>
327

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion 4.5

Table of Contents