Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1161

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
When you create objects and access class methods and fields, and convert data types between ColdFusion and .NET,
be aware of the following considerations and limitations:
• Data type conversion considerations described in
page 1157
• Limitations described in the "Limitations" section of cfobject: .NET object in the CFML Reference.
Instantiating objects and calling class constructors
When you use the
cfobject
ColdFusion creates the object instance in either of the following cases:
• If the class has a default constructor, ColdFusion automatically calls the constructor when you first invoke a non-
static method of the object.
• If the class does not have a default constructor, or if the class has multiple constructors and you do not want to use
the default, call the special
methods for all class constructors. Using the
corresponding number and types of parameters. For example, the following tags cause ColdFusion to call the
MyClass constructor that takes two integer parameters:
<cfobject type=".NET" name="myObj" class="com.myCo.MyClass"
assembly="c:\assemblies\myLib.dll">
<cfset myObj.init(10, 5)>
Note: ColdFusion does not create instances of objects if you use only their static methods.
Calling methods
You call .NET methods in the same way that you use any other ColdFusion object methods. For example, if the
MyClass class has a
getName
follows:
<cfset theID="2343">
<cfset userName=mObj.getName(theID)>
Getting and setting fields
You can access and change public fields of any .NET class by calling the following methods:
Get_fieldName()
Set_fieldName(value)
For example, if the .NET class has a public field named
and
Get_accountID()
Set_accountID()
<cfobject type=".NET" class="com.myCo.MyClass"
assembly="c:\assemblies\myLib.dll" name="myObj">
<cfset theAccount=myObj.Get_accountID()>
<cfset myObj.Set_accountID(theAccount + 1)>
You can access, but not modify final fields, so you can only call
"Converting between .NET and ColdFusion data
tag to create a .NET object, ColdFusion does not create an instance of the object.
method of the ColdFusion object. The
init
method causes ColdFusion to call the class constructor with the
init
method that takes a numeric ID and returns a name, you would call the method as
accountID
methods, as follows:
Last updated 1/20/2012
tag automatically creates
cfobject
, you can access and change its value by using the
fieldName
for these fields.
Get_
()
1156
types" on
init

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents