Re: CFPARAM doesn't work as expected

2007-12-25 Thread s. isaac dealey
> Thanks Isaac, I didn't know cfparam executed the default value
> anayway and _then_ looks if it is needed... this explanation makes
> sense. I used the StrutKeyExists() function.

Welcome. Of course, it still shouldn't overwrite your object, but
generally speaking not the best way to instantiate them.

-- 
s. isaac dealey  ^  new epoch
 isn't it time for a change? 
 ph: 503.236.3691

http://onTap.riaforge.org



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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


Re: CFPARAM doesn't work as expected

2007-12-25 Thread marc --
Thanks Isaac, I didn't know cfparam executed the default value anayway and 
_then_ looks if it is needed... this explanation makes sense.
I used the StrutKeyExists() function.
Marc 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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


Re: CFPARAM doesn't work as expected

2007-12-25 Thread Todd
>From everything I've read and have been told, you don't need to cflock your
Application / Sessions that are within the OnApplicationStart and
OnSessionStart unless... you call OnApplicationStart() / OnSessionStart()
from somewhere else in the code.

On Dec 25, 2007 5:06 PM, s. isaac dealey <[EMAIL PROTECTED]> wrote:

> Which is probably what I would do. Heck I might even wrap a named cflock
> around that cfif statement just in case because iirc the server doesn't
> single-thread the application start.
>
> hth,
> ike
>


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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


Re: CFPARAM doesn't work as expected

2007-12-25 Thread s. isaac dealey
It sounds to me like if the objects are being _assigned_ on each request
that it may be a bug... but make sure you check your application timeout
in your Application.cfc or CFApplication tag (whichever you're using) to
make sure you didn't accidentally assign it a really short timeout of
say a couple seconds that may be causing the application to timeout
between requests. 

However... even if the value already exists in the application and the
cfparam tag behaves correctly, I would say this is probably not the way
you want to create your component objects. It would probably be a lot
better to use the onApplicationStart method of your Application.cfc or
optionally if you don't have one, to use 


  
  yadda...


The reason for this may not be immediately obvious from looking at the
tags. The cfparam tag receives all its input _before_ it assigns
anything, so for example, if you were to say: 



This line will error out if variables.x is undefined, even if form.x
*is* defined. Why? Well, because it doesn't do anything with the input
until it has all the input, so it's looking for the default value before
it checks to see if there's an existing definition. Had I written the
engine I might have written it differently, but... I digress... 

The long and the short of it is that if you use cfparam and put a
CreateObject() call in the default attribute, it's going to create one
every time the param tag executes it, whether it's used of not. So even
if it were retaining your application variables the way you wanted them
to, the server would still be doing a bunch of extra, unnecessary work,
creating new ones on each request.

Now there is an alternative that you may or may not like that allows you
to do basically what you were hoping for and at the same time prevent
the server from creating a whole bunch of components it's not going to
use: 


  










  




The iif() function unlike the cfparam tag accepts strings as input
instead of the result variables and then determines which one to
evaluate once it's received it's input. So in this case, if
application.objects exists, then the string containing the CreateObject()
code isn't evaluated and it doesn't create that extra object that's
created by the cfparam tag. 

Or you could just: 


  


Which is probably what I would do. Heck I might even wrap a named cflock
around that cfif statement just in case because iirc the server doesn't
single-thread the application start. 

hth,
ike

-- 
s. isaac dealey  ^  new epoch
 isn't it time for a change? 
 ph: 503.236.3691

http://onTap.riaforge.org



~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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


RE: CFPARAM doesn't work as expected

2007-12-25 Thread Dave Watts
> I thought cfparam only assigns the default value if the 
> variable doesn't exist but here it executes it every time.

I would recommend that you not use CFPARAM in this case. First, there have
been similar problems with CFPARAM creating complex objects in the past.
Second, and perhaps more importantly, there's significantly more overhead in
checking for the existence of each of these objects in the Application scope
before creating them, compared to checking for the existence of just one
(or, even better, avoiding the need to check for any by placing the creation
code in your onApplicationStart method).

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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


RE: CFPARAM doesn't work as expected

2007-12-25 Thread Dave Watts
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information! 

> -Original Message-
> From: marc -- [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 25, 2007 08:22
> To: CF-Talk
> Subject: CFPARAM doesn't work as expected
> 
> In Applicationb.cfm I have these lines:
> 
>  default="#CreateObject('component','components.security').init
> (authorization='public',language=Left(CGI.HTTP_ACCEPT_LANGUAGE,2))#">
>  default="#CreateObject('component','components.util')#">
>  default="#CreateObject('component','components.db').init(dsn='
> irama',maxStringLength=25)#">
>  default="#CreateObject('component','components.cms').init()#">
> 
> First time the page gets requested, there's nothing in the 
> APPLICATION scope so the lines "CreateObject().init*()" are 
> executed. On subsequent calls the APPLICATION scope contains 
> all the objects so I expect that the default values 
> (CreateObject().init()) don't get assigned.
> But they do! I put a cfdump in the init handler and _every_ 
> time a page gets requested it gets executed. So every time my 
> objects get initialized and previous data is lost.
> I thought cfparam only assigns the default value if the 
> variable doesn't exist but here it executes it every time.
> Is this a bug or as designed?
> 
> 
> 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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


Re: CFPARAM doesn't work as expected

2007-12-25 Thread Todd
Yeah, you shouldn't be using cfparam like this at all.

On Dec 25, 2007 8:21 AM, marc -- <[EMAIL PROTECTED]> wrote:

> In Applicationb.cfm I have these lines:
>
>  default="#CreateObject('component','components.security
> ').init(authorization='public',language=Left(CGI.HTTP_ACCEPT_LANGUAGE
> ,2))#">
>  default="#CreateObject('component','components.util')#">
>  default="#CreateObject('component','components.db
> ').init(dsn='irama',maxStringLength=25)#">
>  default="#CreateObject('component','components.cms').init()#">
>
> First time the page gets requested, there's nothing in the APPLICATION
> scope so the lines "CreateObject().init*()" are executed. On subsequent
> calls the APPLICATION scope contains all the objects so I expect that the
> default values (CreateObject().init()) don't get assigned.
> But they do! I put a cfdump in the init handler and _every_ time a page
> gets requested it gets executed. So every time my objects get initialized
> and previous data is lost.
> I thought cfparam only assigns the default value if the variable doesn't
> exist but here it executes it every time.
> Is this a bug or as designed?
>
>


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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


CFPARAM doesn't work as expected

2007-12-25 Thread marc --
In Applicationb.cfm I have these lines:






First time the page gets requested, there's nothing in the APPLICATION scope so 
the lines "CreateObject().init*()" are executed. On subsequent calls the 
APPLICATION scope contains all the objects so I expect that the default values 
(CreateObject().init()) don't get assigned.
But they do! I put a cfdump in the init handler and _every_ time a page gets 
requested it gets executed. So every time my objects get initialized and 
previous data is lost.
I thought cfparam only assigns the default value if the variable doesn't exist 
but here it executes it every time.
Is this a bug or as designed?


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

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