Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 700
  • Last Modified:

Coldfusion 8 CFSWITCH error

Please see the test case...for some reason the string 2f generates an error here for CF8 that it did not generate in CF7 (see below)...we have this type of setup all through out our application so of course our move to CF8 broke it in many places...Any thought as to why this error comes up? Any help is appreciated..Thanks in advance

ERROR:
Context validation error for the cfcase tag.  
The cfswitch tag has a duplicate cfcase tag for value {ts '1900-01-01 00:00:00'}.  
 
ColdFusion cannot determine the line of the template that caused this error. This is often caused by an error in the exception handling subsystem.  

<cfset x = "2f">
 
<cfswitch expression="#x#">
 
	<cfcase value="2a">2a</cfcase>
	<cfcase value="2b">2b</cfcase>
	<cfcase value="2c">2c</cfcase>
	<cfcase value="2d">2d</cfcase>         
	<cfcase value="2e">2e</cfcase>         
	<cfcase value="2f">2f</cfcase>                
 
</cfswitch>

Open in new window

0
tboykin
Asked:
tboykin
  • 4
  • 3
  • 2
  • +1
1 Solution
 
duncancummingCommented:
It must be mis-recognising the hex value as a date!  Maybe try using the ToString() function to prevent that.

 
<cfswitch expression="#ToString(x)#">

0
 
_agx_Commented:
The code above does not seem related to the error described:   Can you post the correct code?

ERROR:
Context validation error for the cfcase tag.  
The cfswitch tag has a duplicate cfcase tag for value {ts '1900-01-01 00:00:00'}.  
0
 
duncancummingCommented:
Also you may want to try putting a cfdefaultcase in there too.  That shouldn't fix your problem, but is probably a good idea anyway (some languages force you to specify the default in a switch; CFML doesn't)
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
_agx_Commented:
> It must be mis-recognising the hex value as a date!

Possibly.  For what is worth, the example code works fine for me with CF8.
0
 
SidFishesCommented:
agree with agx

"The cfswitch tag has a duplicate cfcase tag for value {ts '1900-01-01 00:00:00'}.  "

doesn't relate to the code posted...the error must be somewhere else

that error message means

<cfswitch expression="#x#">
 
        <cfcase value="AVALUE">2a</cfcase>
        <cfcase value="AVALUE">2b</cfcase>
      <cfcase value="ADIFFERENTVALUE">2b</cfcase>
</cfswitch>

somewhere in your code you've got 2 cfcases with the same  value=""


0
 
tboykinAuthor Commented:
Thanks for taking a look at this everyone....

My CF file has EXACTLY what you see in the code snippet....I agree it doesn't make sense, but that is the error it generates....however, if I remove "<cfcase value="2f">2f</cfcase>" from the code it doesn't throw the error...its as if its looking at the value "2F" and trying to convert it to a date OR when it deciphers value="2F" it is coming back with the same value as one of the other options???

Here is something else I found on the web:
here is the reason: ColdFusion 8: Changed the way ColdFusion parses cfcase values. Previously, cfcase tags with numeric value dates did not return expected results. For example, <cfcase value="00"> and <cfcase value="0A> were both evaluated to 0. The value "0A" was treated as a date and converted to 0 number of days from 12/30/1899. The value "00" was also evaluated to the value 0. This caused the exception "Context validation error for tag CFCASE. The CFSWITCH has a duplicate CFCASE for value "0.0"." The cfswitch tag now returns the expected result.
0
 
tboykinAuthor Commented:
An example of the exact error message is here:

http://dev.projects.uxgroup.com/cfcase.cfm

The snippet attached is exactly whats at the URL above


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
<body>
 
<cfset x = "2f">
 
<cfswitch expression="#ToString(x)#">
 
	<cfcase value="2a">2a</cfcase>
	<cfcase value="2b">2b</cfcase>
	<cfcase value="2c">2c</cfcase>
	<cfcase value="2d">2d</cfcase>         
	<cfcase value="2e">2e</cfcase>         
	<cfcase value="2f">2f</cfcase>                
 
</cfswitch>
 
 
</body>
</html>

Open in new window

0
 
SidFishesCommented:
that a hot fix technote?

I'm fully patched & agx must be since it works for him as well...

patch up and you should be fine

(duncan...are we behind on our patch schedule??? tsk tsk ;)

0
 
SidFishesCommented:
hmmm... that's very weird... doesn't appear that it -is- a cf8 early release issue (bug)

my reading of http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_c_03.html is that -by default- this shouldn't be a problem -at all- in cf8

so my first question is are you sure you're parsing against cf8 ? what does this return #server.coldfusion.productversion#

(and second...how did this work in cf7 (maybe that was a hotfix item???)
0
 
tboykinAuthor Commented:
#server.coldfusion.productversion#
rendered the following:
8,0,0,176276 2d

I am going through the 8.0.1 updater later tonight and will see if that helps at all as suggested
0
 
tboykinAuthor Commented:
I ran the 8.0.1 updater...Once patched the issue was resolved and the code rendered correctly without an error...You guys are all great and I appreciate your help and quick response!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now