Solved

Coldfusion 8 CFSWITCH error

Posted on 2009-05-06
11
638 Views
Last Modified: 2013-12-24
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
Comment
Question by:tboykin
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 16

Expert Comment

by:duncancumming
ID: 24318410
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
 
LVL 52

Expert Comment

by:_agx_
ID: 24318426
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
 
LVL 16

Expert Comment

by:duncancumming
ID: 24318474
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
 
LVL 52

Expert Comment

by:_agx_
ID: 24318506
> 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
 
LVL 36

Expert Comment

by:SidFishes
ID: 24319006
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
Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

 

Author Comment

by:tboykin
ID: 24319117
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
 

Author Comment

by:tboykin
ID: 24319193
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
 
LVL 36

Accepted Solution

by:
SidFishes earned 125 total points
ID: 24319201
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 24319457
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
 

Author Comment

by:tboykin
ID: 24319728
#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
 

Author Closing Comment

by:tboykin
ID: 31578659
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

Superior storage. Superior surveillance.

WD Purple drives are built for 24/7, always-on, high-definition security systems. With support for up to 8 hard drives and 32 cameras, WD Purple drives are optimized for surveillance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now