Skip to Main Content
Programming ColdFusion MX, 2nd Edition
book

Programming ColdFusion MX, 2nd Edition

by Rob Brooks-Bilson
August 2003
Intermediate to advanced content levelIntermediate to advanced
1140 pages
68h 45m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion MX, 2nd Edition

Name

JavaCast

Synopsis

                  
                  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)>
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming ColdFusion

Programming ColdFusion

Rob Brooks-Bilson

Publisher Resources

ISBN: 0596003803Supplemental ContentErrata Page