Question
CFC Init problem
I'm trying to create a cfc in my application scope but the
variables I set in the init method don't seem to be persistent.
Here is the init method:
<cfcomponent displayname="coupons" hint="Checks validity and type of coupon and applies it to order."> <cffunction name="init" access="public" output="false" returntype="coupon"> <cfargument name="ds" required="true" type="string" <cfset variables.ds=arguments.ds> <cfreturn this> </cffunction>
Here's the call in the Application.cfc
<cfset Application.coupons = createObject("component", "coupon").init(application.admin.ds)>
Here is the method that throws the "variables.ds not defined error"
<cfstoredproc procedure="pr_getCouponList" datasource="#variables.ds#" debug="Yes"> <cfprocparam type="In" cfsqltype="CF_SQL_INTEGER" dbvarname="@Active" value="#arguments.Active#" null="No"> <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" dbvarname="@Sort" value="#arguments.gridSortColumn#" null="No"> <cfprocresult name="getCouponList" resultset="1"> </cfstoredproc>
<cfcomponent displayname="coupons" hint="Checks validity and type of coupon and applies it to order."> <cffunction name="init" access="public" output="false" returntype="coupon"> <cfargument name="ds" required="true" type="string" <cfset variables.ds=arguments.ds> <cfreturn this> </cffunction>
Here's the call in the Application.cfc
<cfset Application.coupons = createObject("component", "coupon").init(application.admin.ds)>
Here is the method that throws the "variables.ds not defined error"
<cfstoredproc procedure="pr_getCouponList" datasource="#variables.ds#" debug="Yes"> <cfprocparam type="In" cfsqltype="CF_SQL_INTEGER" dbvarname="@Active" value="#arguments.Active#" null="No"> <cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR" dbvarname="@Sort" value="#arguments.gridSortColumn#" null="No"> <cfprocresult name="getCouponList" resultset="1"> </cfstoredproc>
