Name
JavaCast — New as of ColdFusion 4.5
Synopsis
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)>
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.