Remote Synthesis
Search my blog:

Viewing by month: October 2005

Sorry for the lack of posts lately, but at work I am stuck in the land of copy-paste globalization and any improvement to that situation seems mired in corporate politics and bureaucracy. Besides that, I have been a proponent of a regular column in CFDJ covering open-source projects. The growth of open-source available to ColdFusion developers in the past three years has been fantastic, and I think belies the common perception that the CF community does not share. For one reason or another (and despite pretty solid community support I think), this doesn't appear as if it will be happening in CFDJ. Therefore, I plan to still proceed with my idea, and post them here.

My first "article" will cover Barney Boisvert's TreeManager CFC. I am about 90% complete with a flash form based tree administration tool that relies upon a (modified) version of TreeManager CFC. The nice thing is it utlizes a number of techniques in order to manage the tree without any page loads (other than the initial of course). I expect to be complete with this within the next day or so, and will write up the results (and make the code available).

My hope is that by doing something like this I am able to promote a CF open-source project and offer some help to people who may wish to use it. This doesn't exclude CFDJ deciding to run this column of course (I still think it is probably the proper location to reach the broadest audience), but until they change their mind, at least the idea has a home.

Oct 21, 2005

Handling Unique IDs

Recently, in my spare time I have been working with Doug Hughes' Reactor framework. It is still in an early beta release, but so far I am very excited by the project. Something about the way it works suits my programming style and feels comfortable for me. I have been having alot of discussion with Doug via his blog about handling certain issues that have arisen, the most recent over how to handle calling insert or update for the record. The question seems simple but in part comes down to differing ways of handling creating unique IDs for records, and, perhaps, how my means of handling this may differ from common practice (I am not sure to be honest if this is the case or not - which is the reason for my post)

A coworker of mine brought this issue to my attention. In my tests, you cannot modify a date object created using ActionScript in a Flash form. In his attempts and mine as well, no matter how we manipulate a date, it always comes back with the current date/time. For example:

<cfform format="flash" name="form1" onload="{setItem();}">
   <cfformitem type="script">
      function setItem() {
         var theDate:Date = Date(2004,9,1);
         alert(theDate.toString());
         theDate.setFullYear(1974,7,16);
         alert(theDate.toString());
      }
   </cfformitem>
</cfform>

The first alert will show today's date/time and the second exactly the same. I also tried other methods listed under the date class with the same effect. Perhaps it is because Flash forms disallow the new keyword? Anyone run into this issue? Anyone have a solution?

Sorry for the lack of posts recently, but I have been stuck in the land of copy/paste internationalization (which is both a bad way to do things and pure torture to implement...but more on that later). Anyway, I was modifying Barney Boisvert's TreeManager CFC for a side project I still maintain. The component was written for MySQL but for the most part the only MySQL specific code appears to be the use of LIMIT instead of TOP. However, in one case (sortChildren()) he uses LIMIT with the following syntax: LIMIT 5,1. Well, in case you aren't aware (I wasn't), the first item in the list is an offset (i.e. it will get the top 1 after the first 5). Turns out that there does not appear to be a MS SQL equivalent to this (Pete Freitag had discussed this and asked about a MS SQL equivalent but I did not see an answer). However, the following query appears to work (it was tested against the categories table in Northwind):

SELECT TOP 1 *
FROM categories
WHERE categoryid NOT IN (SELECT TOP 4 categoryid FROM categories)

Using that, you could change lines 447-451 of treemanager.cfc to:

SELECT TOP 1 #variables.id# AS id
FROM #table#
WHERE #variables.id# IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#getChildIds(parentID)#" list="true" />)
AND id NOT IN (SELECT TOP #i - 1# #variables.id# FROM #table#)
ORDER BY #lpos#

I am in the early stages, so I haven't tested that yet, but it should work. If anyone knows a better method to acheive this, please let me know. Once I get all the code MS SQL compatible in treemanager.cfc, I hope to send it off to Barney so he can make it available.

|