It is important to remember that there is 2 Variables scope in play here:

The Variables scope of the CFC.
The Variables scope of the CFM.

They are NOT the same.

However, things get funky when you use onRequest. The mere presence of
onRequest will copy the Variables (and the This scope and the methods)
from your Application.cfc file into your CFM file. So you could define
a UDF in onRequestStart and since your onRequest exists, it will be
copied over. However, that tends to bug me. And if you stop using
onRequest, then you can't use this 'by product' of the method.

So I'll ditto others. Use the Request scope. It makes sense and helps
keep your Variables scope a bit cleaner. (Your Variables should really
just be what are defined on the page itself.)


On 3/12/07, Peter Boughton <[EMAIL PROTECTED]> wrote:
> Variables (of some form) does exist and is usable:
> <cfcomponent>
>
>         <cffunction name="OnRequestStart">
>                 <cfset Apple = "Apple"/>
>                 <cfset Request.Ball = "Ball"/>
>                 <cfset Variables.Camel = "Camel"/>
>         </cffunction>
>
>         <cffunction name="OnRequest">
>                 <cfdump var="#Apple#"/>
>                 <cfdump var="#Request#"/>
>                 <cfdump var="#Variables#"/>
>         </cffunction>
>
> </cfcomponent>
>
> This all worked.
> The Variables in the third dump contained both Apple and Camel.
>
> >I am not sure if the "public" VARIABLES scope exists in the
> >OnRequestStart() event method. It might not exist until OnREquest(). If
> >it does, you are probably gonna get all kinds of conflicting issues
> >since VARIABLES is ALSO a scope within the Application.cfc component.
> >
> >Try this... Don't scope the variable at all. Just set variable names.
> >ColdFusion by default puts these into the VARIABLES scope of the page.
> >However, since you are in a component, this might not work (they might
> >go into THIS scope).
> >
> >Try the non-scoping method and see if that works.
> >
> >
> >.....................
> >Ben Nadel
> >Certified Advanced ColdFusion MX7 Developer
> >www.bennadel.com
> >
> >Need ColdFusion Help?
> >www.bennadel.com/ask-ben/
> >
> >-----Original Message-----
> >From: Leitch, Oblio [mailto:[EMAIL PROTECTED]
> >Sent: Monday, March 12, 2007 10:48 AM
> >To: CF-Talk
> >Subject: RE: variables scope & app.cfc methods
> >
> >Thank you for the work around.  However, I was asking about the
> >variables scope, not the request scope.  If it can't be done, I'd rather
> >know that.
> >
> >Oblio
> >
> >-----Original Message-----
> >From: Peter Boughton [mailto:[EMAIL PROTECTED]
> >Sent: Monday, March 12, 2007 10:01 AM
> >To: CF-Talk
> >Subject: Re: variables scope & app.cfc methods
> >
> >Um, put it in the Request scope?
> >
> >> Does anyone know how to write a variables.var in the onRequestStart()
> >> and be able to read it onRequest()?  The usual suspects don't seem to
> >> work.
> >
> >This email message may contain privileged and/or confidential
> >information. If you are not the intended recipient(s), you are hereby
> >notified that any dissemination, distribution, or copying of this email
> >message is strictly prohibited. If you have received this message in
> >error, please immediately notify the sender and delete this email
> >message from your computer.
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272370
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to