|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Why is ColdFusion giving me grief over this code?
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306286
Oh yeh, missed that one ;)
----- Excess quoted text cut - see Original Post for more -----
Author: Charlie Griefer
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306278
On Thu, May 29, 2008 at 11:03 AM, Dominic Watson
<watson.dominic@googlemail.com> wrote:
----- Excess quoted text cut - see Original Post for more -----
ya, aaron mentioned that earlier in the thread. very nice. i never
even thought about that route :\
--
A byte walks into a bar and orders a pint. Bartender asks him "What's
wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I
thought you looked a bit off."
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306276
> i think there's a custom tag out there that will automagically put
form/URL vars into an "attributes" scope.
Can be done natively in CF with two lines of code:
request.args = url;
StructAppend(request.args, form);
Et voila
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Andy Matthews
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306271
Yes...
StructKeyExists is better in most cases.
Thanks, everyone, for clearing that up.
On a side note... is it better to use
'structKeyExists(url, 'property_type')'
as opposed to
'isdefined('url.property_type')'
???
And, if so, why?
Thanks,
Rick
----- Excess quoted text cut - see Original Post for more -----
condition.
----- Excess quoted text cut - see Original Post for more -----
Author: Charlie Griefer
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306268
On Thu, May 29, 2008 at 9:13 AM, Rick Faircloth
<Rick@whitestonemedia.com> wrote:
----- Excess quoted text cut - see Original Post for more -----
http://corfield.org/blog/index.cfm/do/blog.entry/entry/isDefined_vs_structKeyExists
--
A byte walks into a bar and orders a pint. Bartender asks him "What's
wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I
thought you looked a bit
off."
Author: Brad Wood
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306266
On a side note... is it better to use
'structKeyExists(url, 'property_type')'
as opposed to
'isdefined('url.property_type')'
===========================================
The answer is a resounding "depends". It depends on:
1) Version of Coldfusion
2) Whether or not the variable exists.
3) How many variables are in the url scope.
My main beef with isdefined is that it scope hunts and if the variable
is not defined it may take longer to return false. Structkeyexists is a
bit more verbose about what you are looking for. The fact of the matter
is you are talking a difference of milliseconds. I have measured a
difference before, but I had to loop thousands of times for it to add up
and that isn't a very reliable test to compare a production app against.
Here's the general consensus on this kind of stuff: Code what is the
easiest to read and maintain. If you have a performance problem with
the code, address it at that time.
~Brad
Author: Gerald Guido
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306267
Slaps head....
On Thu, May 29, 2008 at 12:33 PM, Aar
----- Excess quoted text cut - see Original Post for more -----
Author: Aaron Rouse
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306264
I did not look at the function but out of curiosity why not just use the
StructAppend() built into CF? I often copy the URL scope into the Form on
some of our pages due to not know if a value will be passed in by one or the
other. So I just put in a <cfset StructAppend(FORM, URL, false) /> for
those needs.
On Thu, May 29, 2008 at 11:24 AM, Gerald Guido <gerald.guido@gmail.com>
wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Gerald Guido
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306263
Oh yeah....
Usage: PopulateStruct(form,url)
On Thu, May 29, 2008 at 12:24 PM, Gerald Guido <gerald.guido@gmail.com>
wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Gerald Guido
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306262
I have a function that does that. It is pretty old so don't make fun of
me..... but it works ;)
http://pastebin.com/m6d287cb5
On Thu, May 29, 2008 at 12:14 PM, Loathe <timothy.heald@gmail.com> wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Rick Faircloth
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306260
Thanks, everyone, for clearing that up.
On a side note... is it better to use
'structKeyExists(url, 'property_type')'
as opposed to
'isdefined('url.property_type')'
???
And, if so, why?
Thanks,
Rick
----- Excess quoted text cut - see Original Post for more -----
Author: Loathe
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306261
Steve Nelson had a tag formurl2attributes.cfm
I can't seem to find it for download though.
Charlie Griefer wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Charlie Griefer
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306258
On Thu, May 29, 2008 at 9:02 AM, Charlie Griefer
<charlie.griefer@gmail.com> wrote:
> i think there's a custom tag out there that will automagically put
> form/URL vars into an "attributes" scope. This is how fusebox does it
> by default (and in Model-Glue it's in the 'event')... but I seem to
> recall a custom tag that would accomplish the same end for folks who
> aren't using a framework.
as a followup... here's that custom tag.
http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1001246
--
A byte walks into a bar and orders a pint. Bartender asks him "What's
wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I
thought you looked a bit
off."
Author: Ian Skinner
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306256
Rick Faircloth wrote:
> Can cfswitch tags not be nested inside cfif tags?
>
> Rick
The whole <cfswitch...> tag can be, but not just the first half.
I.E.
<cfif...
<cfswittch>...</cfswitch>
<cfelse>
<cfswitch>...</cfswitch>
</crif>
Allowed.
<cfif...
<cfswittch>
<cfelse>
<cfswitch>
</crif>
</cfswitch>
Not Allowed.
The quikest fix to what you are trying to do would be.
<cfswitch
expression(#iif(isDefined('url.property_type',de(url.property_type),de(form.property_type))#)
But this is they type of solution the usually quickly gets re-factored
into cleaner and simpler code.
Author: Charlie Griefer
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306254
On Thu, May 29, 2008 at 8:57 AM, Rick Faircloth
<Rick@whitestonemedia.com> wrote:
----- Excess quoted text cut - see Original Post for more -----
not like that, no. you need to finish the switch inside of each condition.
would be "better" to do:
<cfif structKeyExists(url, 'property_type')>
<cfset variables.property_type = URL.property_type />
</cfif>
<cfif structKeyExists(form, 'property_type')>
<cfset variables.property_type = form.property_type />
</cfif>
then
<cfswitch expression="#variables.property_type#">
(case statements)
</cfswitch>
i think there's a custom tag out there that will automagically put
form/URL vars into an "attributes" scope. This is how fusebox does it
by default (and in Model-Glue it's in the 'event')... but I seem to
recall a custom tag that would accomplish the same end for folks who
aren't using a framework.
--
A byte walks into a bar and orders a pint. Bartender asks him "What's
wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I
thought you looked a bit off."
Author: Barney Boisvert
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306251
you have to close the CFSWITCH tag
On Thu, May 29, 2008 at 8:57 AM, Rick Faircloth
<Rick@whitestonemedia.com> wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Loathe
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306253
You need to have a closing cfswitch containing cfcases for it to work.
Rick Faircloth wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Rick Faircloth
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56551#306250
?
<cfif isdefined('url.property_type')>
<cfswitch expression='#url.property_type#'>
<cfelse>
<cfswitch expression='#form.property_type#'>
</cfif>
It's complaining with this error:
Context validation error for the cfelse tag.
The tag must be nested inside a CFIF tag.
Can cfswitch tags not be nested inside cfif tags?
Rick
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||