How to use init function in coldfusion.Could any one explain with a good simpla example.
And also scopes(VARIABLES and THIS) while writing an init function in a component.
fiju
0
Newbie Poster
Recommended Answers
Jump to Postinit() 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" …
Jump to Postreturn a reference to this component
I just meant return the object you created. That's basically what <cfreturn this> does. When used inside a component, THIS means "the component itself".
<cfcomponent> <cffunction name="init" output="false" returntype="MyComponent"> .... <!--- Return the component so the calling page can use it …
All 6 Replies
arrgh
22
Posting Whiz
fiju
0
Newbie Poster
arrgh
22
Posting Whiz
fiju
0
Newbie Poster
Heru_1
0
Newbie Poster
anita.jena
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.