Solved

Coldfusion 8 CFSWITCH error

Posted on 2009-05-06
11
637 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
Comment Utility
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_
Comment Utility
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
Comment Utility
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_
Comment Utility
> 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
#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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

14 Experts available now in Live!

Get 1:1 Help Now