data lost between CFCs

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. #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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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.

    > site = createObject("component","site");
    > site.init();
    > db = createObject("component","db");
    How are you trying to reference site's public variables from within db?

    > And yes, the extends properties are properly setup. :)
    Nothing in what you've detailed suggests anything extending anything
    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

  4. #3

    Default Re: data lost between CFCs

    On 2005-05-05 00:59:05 -0500, "mate of the state"
    <webforumsuser@macromedia.com> said:
    >
    > 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. :)
    I may be misunderstanding your explanation, but I'm not getting how
    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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139