|
Init method for coldfusion cfc's |
I'm lucky enough to be working in an environment that is small enough to allow me access to our whole suite of coldfusion cfc's. So i generally know pretty much what they all do, but what if your interrogating unknown cfc's?
Well you can use the init() method.
'Best Practice' would dictate that there is an init() method in every cfc. In fact its something that I've only recently starting doing out of habit, it used to be more of a 'as and when you need it' kind of thing. But with an ever increasing function library, I've found it essential.
The idea is that the 'this' scope is specific to the cfc instance created. So doing this:
2
3 <cfreturn this>
4 </cffunction>
Will return all of the functions and definitions for the current cfc. Invoke it however you will:
2<cfinvoke component="purchaseOrder" method="init" returnvariable="test">
3
4<cfdump var="#test#">
And you'll see a schema for the whole cfc!
There are no comments for this entry.
[Add Comment] [Subscribe to Comments]