Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Don't quite get it,how to use init() properly

$
0
0

Hi, I'm still confuse with the use of init() with cfc.

If I only have the init function on my cfc but I don't set anything within the init(), for example:

<cfcomponent> <!--- For example I have this init() within my component but I don't set anything --->

 

   <CFFUNCTION name="Init" access="public" returntype="any" output="false" hint="Returns an initialized component instance.">

    <cfreturn THIS ></cfreturn>

  </CFFUNCTION>

 

<!--- Then I have many more functions below --->

<CFFUNCTION name="ValidateEmpId">

    <!---- validation codes here --->

</CFFUNCTION>

 

<CFFUNCTION name="ValidateEmpSal">

  <!---- validation codes here --->

</CFFUNCTION>

 

<CFFUNCTION name="ValidateAddr">

  <!---- validation codes here --->

 

<CFRETURN Sal>

</CFFUNCTION>

 

</cfcomponent>

 

<!--- When I call this init() from my .cfm this way, what will happen? I don't have anything set within my init(). Is this wrong? --->

 

<cfset myObj = createObject("component", "MyComponent").init()>

<cfinvoke component="#myObj#" method="ValidateEmpSal" EmpId="#empId#>

 

<cfinvoke component="#myObj#" method="ValidateAddr" EmpId="#empId#>


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>