House of Fusion
Home of the ColdFusion Community

Search cf-talk

November 20, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
             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             

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Why is ColdFusion giving me grief over this code?

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
?
Rick Faircloth
05/29/08 11:59 A
you have to close the CFSWITCH tag
Barney Boisvert
05/29/08 12:02 P
On Thu, May 29, 2008 at 8:57 AM, Rick Faircloth
Charlie Griefer
05/29/08 12:04 P
On Thu, May 29, 2008 at 9:02 AM, Charlie Griefer
Charlie Griefer
05/29/08 12:10 P
Thanks, everyone, for clearing that up.
Rick Faircloth
05/29/08 12:15 P
On Thu, May 29, 2008 at 9:13 AM, Rick Faircloth
Charlie Griefer
05/29/08 12:38 P
Yes...
Andy Matthews
05/29/08 12:51 P
On Thu, May 29, 2008 at 11:03 AM, Dominic Watson
Charlie Griefer
05/29/08 02:16 P
Oh yeh, missed that one ;)
Dominic Watson
05/29/08 02:52 P
Oh yeah....
Gerald Guido
05/29/08 12:28 P
Slaps head....
Gerald Guido
05/29/08 12:37 P
Rick Faircloth wrote:
Ian Skinner
05/29/08 12:06 P
On a side note... is it better to use
Brad Wood
05/29/08 12:37 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/29/2008 11:59 AM

? <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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
05/29/2008 12:02 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Loathe
05/29/2008 12:02 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Charlie Griefer
05/29/2008 12:04 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Charlie Griefer
05/29/2008 12:10 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/29/2008 12:15 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Charlie Griefer
05/29/2008 12:38 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andy Matthews
05/29/2008 12:51 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
05/29/2008 02:05 PM

> 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Charlie Griefer
05/29/2008 02:16 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
05/29/2008 02:52 PM

Oh yeh, missed that one ;) 2008/5/29 Charlie Griefer <charlie.griefer@gmail.com>: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Loathe
05/29/2008 12:15 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Gerald Guido
05/29/2008 12:26 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Gerald Guido
05/29/2008 12:28 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Aaron Rouse
05/29/2008 12:35 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Gerald Guido
05/29/2008 12:37 PM

Slaps head.... On Thu, May 29, 2008 at 12:33 PM, Aar ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Ian Skinner
05/29/2008 12:06 PM

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.

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brad Wood
05/29/2008 12:37 PM

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


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists