Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
mate of the state #1
data lost between CFCs
I have a sort of main application CFC (only running MX6) in which I declare a
struct containing database table names. For example:
this.dbtables = structNew();
this.dbtables.links = 'links';
this.dbtables.links_categories = 'links_categories';
Etc. On initialization of this CFC, I want to loop over that dbtables struct
and append a prefix (#this.dbtables.prefix#) to each table name, something to
identify tables associated with my app in the database. To do that, I use the
following (part of the init() method):
<CFloop collection="#this.dbtables#" item="key">
<CFif key neq "prefix">
<CFset this.dbtables[key] = this.dbtables.prefix & this.dbtables[key]>
</CFif>
</CFloop>
By doing a <CFdump> on that dbtables struct at various points in the CFC
chain, I've determined that the values are being updated as they should when
the main CFC initializes, but that once the next CFC (a generic DB manipulation
object) tries to reference the values, they are returned as they are originally
declared, without the prefix appended.
The CFCs in question are instantiated and invoked like so in my
Application.cfm template:
site = createObject("component","site");
site.init();
db = createObject("component","db");
And yes, the extends properties are properly setup. :)
mate of the state Guest
-
#38921 [NEW]: pdo lost the first row data:with firebird blob data
From: achun dot shx at gmail dot com Operating system: windows PHP version: 5.1.6 PHP Bug Type: InterBase related Bug... -
Lost data when publishing
When publishing a custom page draft to ebay a substantial amount of data (tables and pictures) were lost. Although some made it through, 75% did... -
Data Lost
I've just installed CFMX 6.1 on my Windows 2003 Server with IIS 6.0. Somehow, when I try to insert or update data from a form, certain fields not... -
lost data in access
Hi I have a form which posts to a cf action page and inserts data into my Access database - but not all of it! I have 63 feilds posting and I have... -
lost all of data after postback....
Since the rows are added manually at runtime, you must keep track of the rows and add them back again each postback. You might use a DataSet to... -
Adam Cameron #2
Re: data lost between CFCs
> I have a sort of main application CFC (only running MX6)
Firstly, if you really mean CFMX 6.0 not CFMX 6.1... I recommend you
upgrade immediately. The implementation of CFCs in 6.0 is a shambles. And
a lot of what one needs to do to get CFCs working in 6.0 will need to be
changed for 6.1 or 7.0.
How are you trying to reference site's public variables from within db?> site = createObject("component","site");
> site.init();
> db = createObject("component","db");
Nothing in what you've detailed suggests anything extending anything> And yes, the extends properties are properly setup. :)
else...?
PS: I'd never use THIS-scoped variables in a CFC for anything that is then
used in internal logic within the CFC. I'd use the THIS scope *only* as a
one-way process: exposing a value to an external entity. I'd never use it
on the RHS of an expression.
Do you NEED these variables in the THIS scope instead of the VARIABLES
scope?
--
Adam
Adam Cameron Guest
-
mpwoodward *TMM* #3
Re: data lost between CFCs
On 2005-05-05 00:59:05 -0500, "mate of the state"
<webforumsuser@macromedia.com> said:
I may be misunderstanding your explanation, but I'm not getting how>
> The CFCs in question are instantiated and invoked like so in my
> Application.cfm template:
>
> site = createObject("component","site");
> site.init();
> db = createObject("component","db");
>
> And yes, the extends properties are properly setup. :)
you're referencing the site CFC's data from your db CFC. It *sounds*
like you're saying that if we saw your code for your db CFC that it
extends the site CFC. Now if you instantiate a site CFC, then set
values in the site CFC, then instantiate a db CFC, it's not going to
know anything about any of the values in the specific instance of the
site CFC. They're two separate objects so the db object wouldn't have
any knowledge of any manipulation you've done to the values in site CFC
unless it calls that object directly.
In other words, this would be the situation:
// instantiate site CFC
site = CreateObject("component", "site");
// set values for attributes in instance of site CFC
site.init();
// instantiate db CFC
db = CreateObject("component", "db");
// this will set the variable to the updated values that were created
in site.init();
myvar = site.getSomeVar();
// this will set the variable to the ORIGINAL values because
// the db object knows nothing about what's going on in the site object
myvar2 = db.getSomeVar();
As I said, I may be misunderstanding what you're saying; it just kind
of sounds like you're expecting that by extending your site CFC in your
db CFC the objects stay "synched" or something, which of course they
don't. Let me know if I'm not getting what you're trying to do.
Matt
--
Matt Woodward
[email]mpwoodward@gmail.com[/email]
Team Macromedia - ColdFusion
mpwoodward *TMM* Guest



Reply With Quote

