Hi,
I have a problem with calling static methods after creating a object:
I am using coldfusion 7.0 and this is my code:
When I am using either <cfobject> or createObject the same
<cfobject action="create" type="java"
class="com.endeca.navigation.ENEQueryToolkit" name="new_N">
<cfset new_N = createObject("java",
"com.endeca.navigation.ENEQueryToolkit")>
<cfdump var = "#new_N#">
<cfset new_N = new_N.selectRefinement(#my_nav_results#,
toString(sample_refinement_value))>
1. CFDUMP tells me that object [unknown type] and [unable to convert to string]
2. When I call a static method new_N.selectRefinement(...) i get "The selected
method selectRefinement was not found."
3. Arguments to selectRefinement() method are of correct datatype
Below are all methods of this class (all are static):
static boolean isImplicitRefinement(Dimension dim, DimVal refinement)
static DimValIdList removeDescriptor(Navigation n, DimVal descriptor)
static DimValIdList selectAncestor(Navigation n, DimVal ancestor, DimVal
descriptor)
static DimValIdList selectRefinement(Navigation n, DimVal refinement)
Any suggestions?
Thank You
insuractive - 29 May 2007 20:29 GMT
First, you don't have to use both createObject() and <cfobject> - one or the
other will suffice (personally, I prefer CreateObject()).
Second, are you sure you have set up the java files correctly in your CF
administrator / classpath? If you have the following code should show you
SOMETHING:
<cfset new_N = createObject("java", "com.endeca.navigation.ENEQueryToolkit")>
<cfdump var="#new_N#">
Until you can get the above code working, your object is not loaded correctly
in CF.
marekss - 29 May 2007 20:57 GMT
I have been using createOject() and my .jar files are in C:\CFusionMX7\lib . I
assume that is correct because I successfully created objects and called
non-static methods on them. Schould <cfdump> print all methods that are
assosiated with this class even though all methods are static? My cfdump output
is clickable box with object [unknown type].
cf_dev2 - 29 May 2007 20:53 GMT
I agree with insuractive. You need to resolve the createObject() problem first.
>static DimValIdList selectRefinement(Navigation n, DimVal refinement)
Then make sure you're passing in the correct object types. Is #my_nav_results#
an instance of "Navigation" and #sample_refinement_value# an instance of
"DimVal"? In any case I don't think you need the toString(..) call.
cf_dev2 - 29 May 2007 22:12 GMT
Yes, placing the jar in C:\CFusionMX7\lib an rebooting is fine.
If the object is valid, Cfdump should print all of its public methods. I
don't know if it prints protected or private methods. I thought the cfdump box
was expanded by default.. but if you click the box does it show the method
names?
marekss - 30 May 2007 01:33 GMT
There are only static methods in this class. My first post lists ALL methods
this class contains, there aren't any public or private methods.
I am passing correct object types, first argument is of type Navigation and
second of DimVal
marekss - 30 May 2007 01:42 GMT
When I click on the <cfdump> box instead of methods i see [unable to convert to
string] on top section of cfdump box I see object [unknown type]. I have read
on lifedocs that in order to call static methods i just have to instantiate
object and then call static methods. For other methods (public, or private) I
have to use init() to initialize the object. I have tested with and without
initialization and it was unsuccessful.
Adam Cameron - 30 May 2007 15:23 GMT
This might help:
http://www.bennadel.com/index.cfm?dax=blog:737.view
If not the article itself, then the links within in.

Signature
Adam
marekss - 30 May 2007 16:18 GMT
After reading http://www.bennadel.com/index.cfm?dax=blog:737.view and all
related articles i found a solution to the problem: Below is a code that works.
First <cfdump> does not give any meaningful results but second <cfdump> after
calling static method returns correct value. The problem was with second
parameter instead #sample_refinement_value# i had
toSring(sample_refinement_value) which caused the error :
Thank you all for the input and suggestions.
<cfset new_N = createObject("java", "com.endeca.navigation.ENEQueryToolkit")>
<cfdump var = "#new_N#">
<cfset new_N = new_N.selectRefinement(#my_nav_results#,
#sample_refinement_value#)>
<cfdump var = "#new_N#">
cf_dev2 - 30 May 2007 23:00 GMT
I knew you didn't need that toString(..) call ;-) Glad its working for you now.