I don't think you can do that in CF5, you should be able to get something
like that working in CFMX though. Structures in CF5 are in C++ memory land,
but in MX they are java objects, so you can pass them around to your own
stuff.

One workaround is to use WDDX, serialize the structure to WDDX, pass it as a
string, and then in the Java class convert the WDDX into a Hashtable.

Another workaround would be to create a UDF or something that converted a CF
structure into a Java Hashtable by looping through the structure. This would
probably perform better than the WDDX solution.

_____________________________________________
Pete Freitag
CTO, CFDEV.COM
http://www.cfdev.com/

-----Original Message-----
From: Correa, Orlando (ITSC) [mailto:Orlando.Correa@;mail.ihs.gov]
Sent: Wednesday, November 13, 2002 1:44 PM
To: CF-Talk
Subject: Passing CF5 Structures to Java


We are experiencing a problem while trying to pass a ColdFusion 5 structure
to a java class that was created using CreateObject. Our java code
conceptually looks something similar to:

public class javaTest {

  public static int testThis(Hashtable testVal) {

        return 7;

  }

}

The call in Cold Fusion is like:

<cfset request.o_test = CreateObject("JAVA", "javaTest")>
<cfloop from=1 to=1000 index="i">
        <cfset x = request.o_test.testThis(CFstructure)>
</cfloop>

where CFstructure is a basic structure (key/value pair) with 2 elements.
We have also tried to cast the structure as a HashMap and an Object and get
the same error each time.

"Unknown exception during conversion of a CF type to a Java type"
Can anyone help us with this?

Thanks...
Anderson, Ryan R. (ITSC)

Also... we are using JRE 1.4.0 JVM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to