August 2003
Intermediate to advanced
1140 pages
68h 45m
English
JavaCast
JavaCast(type, variable)Casts a ColdFusion variable before being passed to an overloaded Java
method. Possible entries for type include
boolean, 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)>