August 2001
Intermediate to advanced
976 pages
38h 8m
English
JavaCast — New as of ColdFusion 4.5
JavaCast(type, variable)Casts a ColdFusion variable before being passed to an overloaded Java
method. Possible entries for type include
bool, int,
long, double, or
string. The JavaCast( )
function can’t cast complex objects, such as query objects,
arrays, and structures, nor can it cast to a super-class. The
following example demonstrates how to explicitly cast a ColdFusion
variable before passing it to an overloaded method within a Java
object:
<CFOBJECT TYPE="Java" ACTION="Create" CLASS="MyClass" NAME="MyObject">
<CFSET x=10>
<!--- cast x to a string --->
<CFSET MyString = JavaCast("string",x)>
<CFSET void = MyMethod(MyString)>
<!--- cast x to an integer --->
<CFSET MyInteger = JavaCast("int",x)>
<CFSET void = MyMethod(MyInteger)>Read now
Unlock full access