Sam,

There's a difference between:

<cfset var foo = "something">

and...

<cfset variables.foo = "something">

Variables.foo goes into the variables scope of the CFC, which means it becomes part of the data the CFC has access to for the whole lifetime of the CFC, i.e. till it either times out or is destroyed.

var foo, on the other hand, dies as soon as the function is done executing. ;) So <cfset var user = reactorfactory.createRecord("User")> means that your user object will cease to be viable one the function it appears in is done running.

It's an important distinction because when you have a MG controller with a record set into it's variables scope, everyone accessing it will see the same values in that record... so, for example, if you did <cfset arguments.event.setValue("userId",variables.userRecord.getUserID())>, every single person hitting that page will see the same value, not the right one.

Think of it this way... setting a value into a Controller's variables scope is effectively the same as setting it into the application scope. For per-user variables you want to use session variables even if you're using MG or any other framework.

As far as your reactor error, I'm not sure what to tell ya. You need to be very sure to delete everything under c:\webroot\reactor\project and then rerun using ?init=true on the URL in your MG application. That'll re-create your Reactor objects and re-run the controller configuration in MG.

You may try restarting the server if you have that luxury.

HTH,
J


------------------------------------------------

Jared C. Rypka-Hauer

Continuum Media Group LLC

http://www.web-relevant.com

Member, Team Macromedia - ColdFusion


"That which does not kill me makes me stranger." - Yonah Schmeidler















On Apr 18, 2006, at 5:39 PM, Sam Clement wrote:

Hey Jared,

Thanks for the advice!  I guess I've been goofing around with some frameworks without understanding all the implications of my choices.  Anwyay, I noticed that Doug uses the var scope when creating objectRecords.  Sounds good to me.  However, can you explain why this better than just re-initiating the variables.objectRecord in an MG controller?  Is this just coding style or like you say A Big Red Flag?

Cheers,

Sam

p.s. I made the changes you recommended and I'm still getting that error.  It's such a simple prototype app (on my dev machine) that I think it might be the new build.  Of course, I could be wrong!




On 4/18/06, Jared Rypka-Hauer <[EMAIL PROTECTED]> wrote:
Sam,

Reinit your MG application, reset the session variable, delete your Reactor project files (/Reactor/project/{project}/*.*), and, most of all, don't put a record object in the variables scope of a MG controller!!

The controllers live in the application scope, so if you have variables.userRecord and that represents an actual Reactor-generated user object, you've just set that value into an application-scope container. Big Red Flag There®.

If you have several users relying on that, or if you handle several requests against that at once, things are going to get alllllll screwed up.

Instead, use onRequestStart() in your MG controller to set a User object into the session scope and call session.User.setCompanyId() and you'll find yourself a LOT happier over time.

HTH,
J


------------------------------------------------

Jared C. Rypka-Hauer

Continuum Media Group LLC

http://www.web-relevant.com

Member, Team Macromedia - ColdFusion


"That which does not kill me makes me stranger." - Yonah Schmeidler


On Apr 18, 2006, at 4:56 PM, Sam Clement wrote:

Hi Doug,

Is the latest SVN code meant to be solid?  If so, I've noticed a weird problem - if not, feel free to ignore the following:

I'm prototypying something pretty simple with 2 tables so far: company & user.

Here is the reactor.xml to show how they relate:
<objects>
        <object name="company" />
       
        <object name="user">
            <hasOne name="company">
                <relate from="companyid" to="companyid" />
            </hasOne>
        </object>
</objects>

Now when I try to process a form and use the method variables.userRecord.setCompanyid() in my MG controller I receive this error:

Element CHILDREN.COMPANY is undefined in VARIABLES.
D:\Webroot\reactor\project\myProject\Record\userRecord.cfc (189)

If I take out the relationship defined in the reactor.xml, the error goes away (but then so does the relationship!)

Investigating the generated userRecord.cfc, I see the following:

<!--- companyid --->
        <cffunction name="setcompanyid" hint="I set the companyid value  and reset related objects." access="public" output="false" returntype="void">
            <cfargument name="companyid" hint="I am this record's companyid value." required="yes" type="string" />
            
                    <!--- if the value passed in is different that the current value, reset the valeus in this record --->
                    <cfif arguments.companyid IS NOT getcompanyid()>
                        
                            <cfif variables.children.company IS NOT 0>
                                <cfset variables.children.company.resetParent() />
                            </cfif>
                            <cfset variables.children.company = 0 />
                        
                        
                        <cfset _getTo().companyid = arguments.companyid />
                        
                        <!--- load the correct address record --->
                        <cfset getAddress() />
                    </cfif>
                    
                
        </cffunction>

The code in red seems to be causing the problem, though not understanding the reactor framework, I can't figure out why.  Any insight would be appreciated.

Cheers,

Sam
-- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/


-- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/

Reply via email to