Solved

Coldfusion 8 CFSWITCH error

Posted on 2009-05-06
11
674 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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
 

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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

636 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