Viewing By Category : coldfusion / Main
August 25, 2008
CF8 Exam Buster
i'm late w/this news but brian's released a new version of his excellent CF Exam Buster for CF8 to help folks prepare for the ColdFusion 8 certification exam.

he's got a nifty demo version so you don't "ซื้อควายในหนอง" (thai idiom, "buying a water buffalo out in the swamp") or "een kat in de zak kopen" (dutch one for "buying a cat in a sack"--cats in sacks seem to be real popular throughout europe).

if you're serious about coldfusion certification then hurry on over to brian's centrasoft site.

April 10, 2008
math precision out your ears
we very often have to deal with scientific data that's been gathered by various sensors or lab equipment, some of it needing math done with a fairly high precision that ColdFusion sometimes couldn't handle. flopping down to java BigDecimal was the usual way of dealing with this. but yesterday in the ColdFusion support forums, Hemant Khandelwal causally mentioned that cf8 had added a new method, precisionEvaluate() for just such cases. i guess it was one of those "senior momements" that made me skip right past this puppy when i was reviewing the new stuff in cf8. in any case, "wow".

<cfscript>
// the old way if you needed the precision bd=createObject("java","java.math.BigDecimal");
bd1=bd.init("234.567890123456");
bd2=bd.init("123.67141525678901345");
x=bd1.multiply(bd2);
// "high" precision math y=precisionEvaluate(234.567890123456*123.67141525678901345);
// "normal" cf math
z=234.567890123456*123.67141525678901345;
writeoutput("<table border='1'>
<tr><td>old fashioned java way</td><td>#x#</td></tr>
<tr><td>new precisionEvaluate</td><td>#y#</td></tr>
<tr><td>normal cf math</td><td>#z#</td></tr>
</table>"
);
</cfscript>

which produces something like:

old fashioned java way29009.34294536678530209026494448320
new precisionEvaluate29009.34294536678530209026494448320
normal cf math29009.3429454

i would imagine that cf's handling the expression parsing and data type casting in the background similar to the above example using BigDecimal.

ps: coldfusion 8 added BigDecimal as one of the data types for javaCast(), so you could ditch the createObject() and use something like this:

zz0=javacast("BigDecimal","234.567890123456");
zz1=javacast("BigDecimal","123.67141525678901345");
zz=zz0.multiply(zz1);

September 1, 2007
more coldfusion 8 cfquery goodness
by now i suppose everyone knows about the new SQL goodness in coldfusion 8's cfquery. by using cfquery's optional result argument you can access identity (auto-increment) values if your database returns them (and of course you actually use them).

one other useful bit of info returned in the result structure is recordcount which according to the docs returns the Number of records (rows) returned from the query. that doesn't sound all that interesting but what it really means is that it returns the number of rows affected by the cfquery's SQL, something akin to sql server's @@ROWCOUNT. so for UPDATEs and DELETEs (at least for sql server using the builtin datadirect and jTDS JDBC drivers that i tested with) you can very easily get at how many rows were deleted or updated without any extra SQL, etc. for instance:

<cfquery datasource="jTDS" name="q" result="r">
   DELETE a
   WHERE ID >= 13050
</cfquery>
<cfdump var="#r#">

will return the number of rows deleted in r.recordcount along with the SQL used, execution time and whether this query is cached. sweet.

note that batching your SQL statements like this:

<cfquery datasource="lab" name="q" result="r">
   <cfloop index="i" to="10" from="1">
   UPDATE a
      SET testA='a'
   </cfloop>
</cfquery>

will only return the affected row count for the last SQL statement (or first, haven't tested which yet). or if you wrap your SQL code in NOCOUNT blocks (in sql server this tells the db not to return row counts to the client):

<cfquery datasource="lab" name="q" result="r">
   SET NOCOUNT ON
   UPDATE a
      SET testA='a'
   SET NOCOUNT OFF
</cfquery>

you won't get anything back for recordcount.

August 1, 2007
cf8 javacast
another interesting coldfusion 8 upgrade that i've kind of glossed over before are the new data types that javacast supports:
  • bigdecimal
  • byte
  • char
  • short

as well as the nifty new ability to cast Arrays (which has been something i'd actually requested a while back):

bigDecimalArray=javacast("bigdecimal[]",cfArray);

very cool.

July 26, 2007
scorpio's i18n changes
in case you were wondering, the main i18n changes for scorpio (coldfusion 8) really revolved around upgrading coldfsion's JDK to version 6. what did that buy us? well core Java's first set of locales based on CLDR data:

  • zh_SG - Chinese (Simplified), Singapore
  • en_MT - English, Malta
  • en_PH - English, Philippines
  • en_SG - English, Singapore
  • el_CY - Greek, Cyprus
  • id_ID - Indonesian, Indonesia
  • ga_IE - Irish, Ireland
  • ms_MY - Malay, Malaysia
  • mt_MT - Maltese, Malta
  • pt_BR - Portuguese, Brazil
  • pt_PT - Portuguese, Portugal
  • es_US - Spanish, United States

hopefully this trend will continue.

beyond the new locale data it also provides support for the Japanese Imperial Calendar which we can tap into for date conversion and formatting simply by setting coldfusion's locale to the new JP variant:

<cfscript>
// set appropriate locale
setLocale("ja_JP_JP");
// Japanese Imperial Calendar date format writeoutput("#lsDateFormat(now(),"FULL")#");
</cfscript>

which should give you something like: 平成19年7月26日 how cool is that?

for more details on the new i18n bits in JDK 6 see this.

June 1, 2007
coldfusion 8 minor flex annoyance
if any of your coldfusion 7 CFC methods have a return type of "any" these will probably fail in coldfusion 8 and flex w/the dreaded TypeError: Error #1009: Cannot access a property or method of a null object reference error. the public beta seems to have made type conversions to flex more "rigorous". you should also watch out for cases where your return type is "struct" and you're really returning a typed object, cf8 will blast away all the object bits & turn the returned object into a real coldfusion structure (ie your object's key case will become UPPER case and since flex is case sensitive this will lead to a certain amount of head scratching). in almost all the cases i've looked at both of these cases were simply sloppy coding/QC (majority were left over from my dithering around about exactly what to return to flex, "any" worked well in those cases ;-) & could be "fixed" in a few seconds.

while it's a short term annoyance i think this is probably for the better long term.

update: tom jordahl's mentioned that the "any" bit will get fixed for the final release.

April 28, 2007
g11n chapter: anything else need covering?
in case you missed it, there's a new edition of the ever popular cf wack (ColdFusion Web Application Construction Kit) on the way. and in case you don't already know, i handled the chapter on cf & globalization (g11n).

given the timezone hell i recently passed through and the recent US and Australia DST changes, i plan on beefing up the section on timezones. and in keeping w/ben's idea to slim things down, we'll be pushing most of those "boring" locale table comparisons out to on-line appendices. might also add a wee bit on using flex in g11n cf apps.

so before i really begin the excruciating process of revising that chapter, i'm looking for feedback on it. anything missing? anything not too clear? you can respond here or simply email me with your suggestions.

thanks.

August 9, 2006
help localize ColdFusion info!
tim buntel's looking for folks who want to help localize ColdFusion information including datasheets, whitepapers, and developer center articles. somebody in the Tawainese user community has already submitted some Chinese (traditional and simplified) stuff.

and i'd also like to remind folks that dean harmon's looking for help localizing the cfreport builder application.

so what are you waiting for?

July 27, 2006
me too....scorpio i18n wishlist
i've never seen a bandwagon i didn't want to jump on, so i'm jumping aboard this round of ColdFusion wishlist blog articles with my own i18n one. but unlike the other wishlists, my i18n list is rather short and sweet. why? over the years ColdFusion has more or less answered the majority of my i18n needs. unicode capability? got it. java locales? yup. and the introduction of CFCs pretty much plugged in the other i18n holes (non-gregorian calendars, locale based collation, etc.). so what do i think ColdFusion still needs in terms of i18n?

  • native resource bundles (heck flex 2.0 got them, but frankly that's about all it got in terms of i18n)
  • setTimeZone() function that might allow me to find my way out of timezone hell
  • use icu4j library (used in a modular/plugin fashion, one of the really sweet things aboout this project is how often it's updated with new functionality and improved locale data from the CLDR). this would buy us better locale data, offer easier access to non-gregorian calendars, etc.

and that's it.

i guess you can take this posting as a stealthy complement to the good work the CF team has done over the years to get ColdFusion to it's current i18n state.

September 8, 2005
help localize cfreport builder
dean harmon, who looks after cfreport, has reported on his blog that you can easily localize cf report builder into your own language. the language files (located under the cf report builder install dir in the Languages dir) are sort of simple key/value pairs with the values being utf-8 encoded. the key/value pairs are delimited using "tab-equal sign-tab" for instance
dragAndDrop[tab]=[tab]drag and drop
while that style's not my cup of tea (i would of course have used java style rb files) but at least you can localize report builder. shows some pretty good foresight. so you folks that spell color with a "u", here's your chance to right that terrible wrong.

July 22, 2005
are you fit enough?
if you're looking to get your ColdFusion MX 7.0 Certification, there's no better way to get "fit" for the actual exam than CentraSoft's CFMX Exam Buster 7.0. a boatload of questions (875 questions w/answers too ;-) covering pretty much all aspects of the actual exam, sort of like a workout w/mike tyson in his hey day except no ear-biting.

and in case you're wondering, brian simmons, who built the exam buster, is a genuine good guy. besides "exam buster" sounds like a pretty good name for comic super hero ;-)