rss
twitter
Find out what I'm doing, Follow Me :)
0

Great article on TDD.

http://research.microsoft.com/en-us/news/features/nagappan-100609.aspx

2

I had an interesting observation about datatype conversion in CF9 when dealing with an error in ORM. I was getting an error that said can't use double for an integer field type (something like that). Now, I know that ColdFusion is datatype "independent". So, all simple variables are of datatype "String". Given that, when we do:

 

<cfset myVar = 1 />
<cfdump var="#getMetaData(myVar).toString()#" />

 

The result is "class java.lang.string". Now, if we perform a sum:

 

<cfset myVar = 1 + 1 />
<cfdump var="#getMetaData(myVar).toString()#" />

 

The result is "class java.lang.Double". I expected it to be integer. I was assuming that on the Java side they will get converted to integer. So, next I tried:

 

	<cfset myVar = javaCast("int",1) + javaCast("int",1) />

 

And the result was still "class java.lang.Double". 

So, is sum of two integer result in a "Double"? I will let people who are more intelligent than me answer and explain that to me.

But, in the mean time it causes issue when dealing with ORM. I was doing something like this:

 

	var hql = "SELECT IsNull(MAX(sortOrder),0) FROM " & arguments.entity.getEntityName() ;
var newSortOrder = ORMExecuteQuery(hql,true) + 1;
arguments.entity.setSortOrder(newSortOrder);

 

This was throwing an error because the datatype of sortOrder field is integer and the type of newSortOrder was "Double". The error can be fixed by using javaCast("int",newSortOrder), but I just changed my select to "IsNull(MAX(sortOrder),0)+1" and it returned me a integer.

Anyone care to explain me why sum of two integer results in a Double in ColdFusion?

1

ColdFusion's built in function getTimeZoneInfo() doesn't allow you to pass a date. It give you the server timezone info and offset as of "now" (as in, when the code is run). 

If you need to find the timezone offset for a specific date, you can use the TimeZone class from java. Here is the code.

 

<cfset myDate = "11/01/09" />
<cfset timeZone = createObject("java","java.util.TimeZone") />
<cfset myTimeZone = timeZone.getTimeZone("America/New_York") />
<cfset myTimeZoneOffset = myTimeZone.getOffset(1,year(myDate),month(myDate),day(myDate),dayOfWeek(myDate),0) />

 

0

I'm slowly migrating to writing script style components. I really started loving it. It's lot faster to write code in script style.

Anyway, today in one of my component I wanted to define the type of a property as a custom class. Since you can't write any code above property definition, on a whim, I tried the import outside of the component declaration and I was pleasantly surprised that it worked as expected!

 

import someClassPath.*;


component {


	property MyClassName myClass;


	public void function init() {


		return this;


	}


}


 

0


Recently came across a really bizarre issue with CFHTTP. Look at the code below:

<cfset variables.protocols = "https://,http://">
<cfset variables.link = "www.adobe.com/products/coldfusion/">
<cfloop list="#variables.protocols#" index="protocol">
    <cfhttp url="#protocol##variables.link#" method="get" timeout="10"/>
    <cfoutput>Status: #cfhttp.StatusCode#<br></cfoutput><cfflush>
</cfloop>



See anything wrong with it? No? Well, here is the output I get:

Status: 200 OK
Status: Connection Failure. Status code unavailable.



And no, both the URL's are valid and you can access them through browser or with CFHTTP outside of CFLOOP. Turns out it's a bug in CFHTTP. When CFHTTP is used inside CFLOOP you can't follow an "https" request with "http" request. Huh? Ya, that's what I thought...

I was ready to file a bug report, but before doing that tested it in CF 9 to see what happens and voila, it works!

So, whatever the bug was, it's fixed in CF 9.

More Results: