• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFC Init problem

Explorer ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

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>
TOPICS
Advanced techniques

Views

286

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

Okay, I figured out the problem but don't know the answer. I am getting this problem when I try to bind the cfc in a grid because the grid is binding a new copy of the cfc instead of the one created in the application scope:

<cfgrid format="html" name="getCouponList" pagesize="#attributes.pageSize#" selectmode="row"
bind="cfc:cfcs.coupon.getCouponList({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{active})">

It works if I call it through an invoke command.

The problem I have now is, how can I bind a cfc in a scope?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 24, 2008 Jun 24, 2008

Copy link to clipboard

Copied

LATEST
On Tue, 24 Jun 2008 05:22:30 +0000 (UTC), athanasiusrc wrote:

> Okay, I figured out the problem but don't know the answer. I am getting this
> problem when I try to bind the cfc in a grid because the grid is binding a new
> copy of the cfc instead of the one created in the application scope:
>
> <cfgrid format="html" name="getCouponList" pagesize="#attributes.pageSize#"
> selectmode="row"
>
> bind="cfc:cfcs.coupon.getCouponList({cfgridpage},{cfgridpagesize},{cfgridsort
> column},{cfgridsortdirection},{active})">
>
> It works if I call it through an invoke command.
>
> The problem I have now is, how can I bind a cfc in a scope?


I'm not sure how to use a variable instead of a CFC in a bind statement (I
don't do much UI type development, so have never needed to know); however
your init() method in your CFC could look to see if there's an instance of
itself in the application scope and if so return that instead of a new
instance of itself. Then you chain your method call thus:

cfcs.coupon.init().getCouponList(etc...)

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation