In just trying out the createobject(...).init(...) method of using a
constuctor, I accidentally missed the brackets off a method call.  I
expected this to throw an error, but no...

contructortest.cfc:
-------------------
<cfcomponent>
  <cfset instance = structnew()>

  <cffunction name="init">
    <cfargument name="arg1">
    <cfargument name="arg2">
    <cfset instance.arg1 = arguments.arg1>
    <cfset instance.arg2 = arguments.arg2>
    <cfreturn this>
  </cffunction>

  <cffunction name="getinstancevars">
    <cfreturn instance>
  </cffunction>

  <cffunction name="somestaticmethod">
    <cfargument name="arg1">
    <cfargument name="arg2">
    <cfreturn arg1 + arg2>
  </cffunction>
</cfcomponent>

constructortest.cfm:
--------------------
<cfset myobj = createobject("component", "contructortest").init("1",
"2")>
<cfdump var="#myobj#">
<cfdump var="#myobj.getinstancevars()#">

<cfset funcref = myobj.somestaticmethod>
<cfdump var="#funcref#">
<cfdump var="#funcref(123, 312)#">

----------------------------------------------------------------------

Check out the second section in the cfm file -- you can grab a reference
directly to a method within a CFC and then use that method outside the
CFC.  I tried it using the getinstancevars() method but got a "Variable
INSTANCE is undefined" error, so obviously this is being used outside
the scope of the CFC.

Is this correct (and expected) behaviour?

Tim.


-------------------------------------------------------
RAWNET LTD - Internet, New Media and ebusiness Gurus.
Visit our new website at http://www.rawnet.com for
more information about our company, or call us free
anytime on 0800 294 24 24.
-------------------------------------------------------
Tim Blair
Web Application Engineer, Rawnet Limited
Direct Phone : +44 (0) 1344 393 441
Switchboard : +44 (0) 1344 393 040
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
-------------------------------------------------------


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to