Init() function in ColdFusion
init() is just a standard convention most people adopt with components. The init() function initializes any variables needed by the component's functions. Then returns a reference to the current component.
ie
Test.cfm<cfset myObj = createObject("component", "MyComponent").init(dsn="My DSN")>MyComponent.cfc<cfcomponent><cffunction name="init" output="false" returntype="MyComponent"><cfargument name="dsn" type="string"><!--- initialize variables used within this component ---><cfset variables.dsn = arguments.dsn><!--- return a reference to this component ---><cfreturn this></cffunction></cfcomponent
Comments
Post a Comment