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

cfajaxproxy and CFCs / init() / this / variables scope

New Here ,
Aug 05, 2007 Aug 05, 2007

Copy link to clipboard

Copied

so, i'm trying to use cfcajaxproxy. after user enters something into text box, i want it to update on the server. i'm using cfcajaxproxy to create an instance of a JS variable tied to the CFC that will do the updating of the database. however, in this CFC i have an init() method that sets the DSN and date . when i try to call it using my JS object, it seems to go through, but when i try to access that variable from another method (called from the same JS object), it says it is not defined. same thing if i use variable scope or this scope...any ideas?? thanks!
TOPICS
Advanced techniques

Views

581

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 ,
Aug 05, 2007 Aug 05, 2007

Copy link to clipboard

Copied

In article <f95mpu$c7q$1@forums.macromedia.com>
"Warpuser"<webforumsuser@macromedia.com> wrote:
> so, i'm trying to use cfcajaxproxy. after user enters something
> into text box, i want it to update on the server. i'm using
> cfcajaxproxy to create an instance of a JS variable tied to the CFC
> that will do the updating of the database. however, in this CFC i
> have an init() method that sets the DSN and date . when i try to
> call it using my JS object, it seems to go through, but when i try to
> access that variable from another method (called from the same JS
> object), it says it is not defined. same thing if i use variable
> scope or this scope...any ideas?? thanks!

When you call the CFC via cfajaxproxy, nothing is calling init().

This is something that catches a lot of people out when they first
start writing remote access CFCs. The remote access CFCs are
constructed on each remote call and the method called and then the CFC
is thrown away.

A typical idiom in this situation is to have your application create
and initialize your CFC and store a reference in, say, application
scope.

Then your remote access CFC (the one you call via cfajaxproxy)
delegates method calls to the same named methods on the CFC in
application scope:

<cffunction name="doSomething" access="remote">
<cfargument name="data"/>

<cfreturn application.modelCFC.doSomething(arguments.data) />

</cffunction>

where application.modelCFC is the CFC you've created and initialized,
passing in DSN and date.

Hope that helps?

Sean A Corfield
An Architect's View -- http://corfield.org/

--
I'm using an evaluation license of nemo since 61 days.
You should really try it!
http://www.malcom-mac.com/nemo

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
New Here ,
Oct 01, 2007 Oct 01, 2007

Copy link to clipboard

Copied

LATEST
Thanks!

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