> For future reference, a Java class's constructor method has the same name
> as the class. If you think the constructor (init) might require arguments,
> you can look through the source code for that method.
I was aware of this, but didn't see that method, used to it being at the top
I guess.
Anyway, still can't get it working.
Unable to find a constructor for class IceKey that accepts parameters of
type ( java.lang.Integer ).
The error occurred in D:\Tools\Web\test.cfm: line 2
1 : <cfobject action="create" type="java" class="IceKey" name="myObj" />
2 : <cfset ret = myObj.init(asc("")) />
3 : <cfdump var="#myObj#" />
I tried, just 1 it said didn't like strings, tried int(1) said it didn't
like doubles, damm I hate this, wasn't CF / Java talking supposed to be
easy?
Regards
Dale Fraser
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Shib71
> Sent: Tuesday, 21 March 2006 15:05 PM
> To: [email protected]
> Subject: [cfaussie] Re: Call Java Class (Java Code Attached)
>
> In Java it is possible to create custom constructors for a class. Often
> these constructors don't take any arguments, but occassionally you come up
> against a class that needs parameters to initialize properly. In those
> cases the class's constructors will require arguments: ie using init()
> will be invalid.
>
> In your case this code is valid:
>
> <cfscript>
>
> myObj = createObject("java", "IceKey").init(3 );
>
> </cfscript>
>
>
> but this isn't:
>
> <cfscript>
>
> myObj = createObject("java", "IceKey").init();
>
> </cfscript>
>
> For future reference, a Java class's constructor method has the same name
> as the class. If you think the constructor (init) might require arguments,
> you can look through the source code for that method.
>
> BTW I have no idea what the argument is for, or whether "3" is a good
> value.
>
> Cheers
> Blair
>
>
> On 3/21/06, Dale Fraser < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >
> wrote:
>
>
> What does that mean in english.
>
> Regards
> Dale Fraser
>
>
> > -----Original Message-----
> > From: [email protected]
> [mailto:[email protected] ] On
> > Behalf Of Shib71
> > Sent: Tuesday, 21 March 2006 14:07 PM
> > To: [email protected]
> > Subject: [cfaussie] Re: Call Java Class (Java Code Attached)
> >
> > That's because the class doesn't have a no-arguments constructor.
> You need
> > to provide an int argument "level".
> >
> > Blair
> >
> >
> > On 3/21/06, Dale Fraser < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> > wrote:
> >
> >
> > This
> >
> > <cfobject action="create" type="java" class="IceKey"
> name="myObj" />
> > <cfset ret= myObj.init() />
> > <cfdump var="#myObj#" />
> >
> > Gives this
> >
> > Error Occurred While Processing Request
> > Unable to find a constructor for class IceKey that accepts
> > parameters of
> > type ( ).
> >
> >
> > The error occurred in D:\Tools\Web\test.cfm: line 2
> >
> > 1 : <cfobject action="create" type="java" class="IceKey"
> > name="myObj" />
> > 2 : <cfset ret=myObj.init() />
> > 3 : <cfdump var="#me#" />
> >
> >
> >
> >
> > Regards
> > Dale Fraser
> >
> >
> > > -----Original Message-----
> > > From: [email protected]
> <mailto:[email protected] >
> > [mailto:[EMAIL PROTECTED] On
> > > Behalf Of Mark Mandel
> > > Sent: Tuesday, 21 March 2006 13:42 PM
> > > To: [email protected]
> <mailto:[email protected]>
> > > Subject: [cfaussie] Re: Call Java Class (Java Code
> Attached)
> > >
> > > To copy paste out of the coldfusion documentation:
> > >
> > >
> >
> http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common
> <http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/commo
> n>
> >
> <http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/commo
> > n>
> > >
> >
> /html/wwhelp.htm?context=ColdFusion_Documentation&file=part_dev.htm
> > >
> > >
> > >
> > > Invoking objects
> > >
> > > The cfobject tag makes Java objects available in
> ColdFusion
> > MX. It
> > > can access any Java class that is available on the JVM
> classpath
> > or in
> > > either of the following locations:
> > >
> > > * In a Java archive (.jar) file in
> web_root/WEB-
> > INF/lib
> > > * In a class (.class) file in web_root/WEB-
> INF/classes
> > >
> > > For example:
> > >
> > > <cfobject type="Java" class="MyClass" name="myObj">
> > >
> > > Although the cfobject
> > >
> >
> <http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000302.htm#2820239
> > > > tag loads the class, it does not create an instance
> object.
> > Only static
> > > methods and fields are accessible immediately after the
> call to
> > cfobject.
> > >
> > > If you call a public non-static method on the object
> without
> > first
> > > calling the init method, there ColdFusion makes an
> implicit call
> > to the
> > > default constructor.
> > >
> > > To call an object constructor explicitly, use the
> special
> > ColdFusion
> > > init method with the appropriate arguments after you use
> the
> > cfobject tag;
> > > for example:
> > >
> > > <cfobject type="Java" class="MyClass" name="myObj">
> > > <cfset ret=myObj.init(arg1, arg2)>
> > >
> > > Note: The init method is not a method of the object,
> but a
> > > ColdFusion identifier that calls the new function on the
> class
> > constructor.
> > > So, if a Java object has an init method, a name conflict
> exists
> > and you
> > > cannot call the object's init method.
> > >
> > > To have persistent access to an object, you must use
> the
> > init
> > > function, because it returns a reference to an instance of
> the
> > object, and
> > > cfobject does not.
> > >
> > > An object created using cfobject or returned by
> other
> > objects is
> > > implicitly released at the end of the ColdFusion page
> execution.
> > >
> > >
> > > Btw - you may want to brush up on your OO vocabulary. I
> think you
> > meant
> > > to say you could 'not find a init method in this class' or
> > something to
> > > that effect.
> > >
> > > Mark
> > >
> > >
> > >
> > > On 3/21/06, Dale Fraser <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Hey,
> > >
> > > I'm no Java guru, but I don't see a constructor
> class or
> > init method
> > > in this
> > > function.
> > >
> > > Regards
> > > Dale Fraser
> > >
> > >
> > > > -----Original Message-----
> > > > From: [email protected]
> > <mailto: [email protected]>
> <mailto:[email protected]>
> > > [mailto: [email protected]
> <mailto:[email protected]> ] On
> > > > Behalf Of Mark Mandel
> > > > Sent: Tuesday, 21 March 2006 13:02 PM
> > > > To: [email protected]
> <mailto:[email protected]>
> > <mailto:[email protected] >
> > > > Subject: [cfaussie] Re: Call Java Class (Java Code
> > Attached)
> > > >
> > > > Actually - what just popped into my head -
> > > >
> > > > Try this -
> > > >
> > > > <cfscript>
> > > > myObj = createObject("java", "IceKey").init();
> > > > </cfscript>
> > > >
> > > > I have found on occasion you actually need to
> explicitly
> > call the
> > > default
> > > > constructor on the Java object, otherwise you get
> > weirdness.
> > > >
> > > > I'm not really sure why it is, I have a feeling it
> may
> > have
> > > something to
> > > > do with static attributes - therefore I tend to
> call
> > init() on all
> > > > constructors by default.
> > > >
> > > > Try that, and see if that works.
> > > >
> > > > Mark
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > E: [EMAIL PROTECTED]
> > > W:
>
>
> <http://www.compoundtheory.com>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---