Skip to main content
Participant
June 23, 2010
Question

Get / Cast a Java Object

  • June 23, 2010
  • 1 reply
  • 341 views

Does anybody know how to get (or Cast) a Java Object returned from a Java method call ?

Example:

<cfset someList = object1.method1(someString, JavaCast("float",someNumber),...)>


This method returns a list of Java object of type "Object2". ie. it returns List<Object2>

Now I attempted to loop thru each objects from the returned list, and invoke some method on them, using code similar to below,

<cfset var="#someList[index]#"/>


but ColdFusion does not seem to understand the object "var" as Java "Object2". Is there any way I can cast the "var" to "Object2"?

Thanks in advance.

Xiaoling

    This topic has been closed for replies.

    1 reply

    June 23, 2010

    "var" is a reserved keyword! You can initialize variables with "var" in the beginning of a component, but do not use it as a variables name:

    <cfset var someVar = "#someList[index]#">