The ColdFire Response Queue

Earlier in the week I blogged about the latest release of ColdFire and briefly mentioned the new request queue feature. I wanted to follow up with some details about this new feature, however in thinking about this blog post I realized that a more correct name would be the response queue, as the queue lists responses from the server which have ColdFire data. So, nevermind what it is called, what can it do?

[More]

ColdFire 1.1.51.59 Released

I just put the next release of ColdFire up on the RIAForge site.

[More]

ColdFire 1.1, Now With Firefox 3 Support

I just uploaded the first ColdFire 1.1 release to RIAForge! This is my first release as the new project manager for ColdFire, so I'm pretty excited.

[More]

ColdFire 1.004

Ray has just released ColdFire 1.004. This version doesn't really offer much in the way of new CF debugging features, but it does lay the groundwork for a new version which will work with Firefox 3. So what's changed?

[More]

The Time is #Now()#

So here is something I ran into recently. Take a look at the following queries:

<cfquery name="insertNow1" datasource="scratch">
INSERT INTO TestTable
(
TestText
,TestDateTime
)
VALUES
(
'Test without queryparam'
,#Now()#
)
</cfquery>

<cfquery name="insertNow2" datasource="scratch">
INSERT INTO TestTable
(
TestText
,TestDateTime
)
VALUES
(
<cfqueryparam value="Test with queryparam" cfsqltype="cf_sql_varchar">
,<cfqueryparam value="#Now()#" cfsqltype="cf_sql_timestamp">
)
</cfquery>

You may expect the above two queries to give you the same results, but they don't. If you don't use cfqueryparam the datetime value is only stored to the second precision.

ID TestText TestDateTime ------ ---------------------------------- ---------------------------- 1 Test without queryparam 2008-02-12 15:31:51.000 2 Test with queryparam 2008-02-12 15:31:51.717

This is because the string representation of a coldfusion.runtime.OleDateTime object is only precise to the second. (Try dumping Now() and you will see you get a time stamp similar to {ts '2008-02-12 15:31:51'}. Notice no milliseconds.) This is just something to keep in mind, especially if your application depends on timestamps.

ColdFire SVN

As you may have heard Ray Camden and Rob Gonda recently made some updates to RIAForge which allow project owners to share SVN access. After this update Ray was kind enough to give me access to the ColdFire repository and since then I've done some reorganizing. So, what will you find in the ColdFire SVN repo?

[More]

ColdFire Security Update

A little over a week ago I became aware a 0-day security exploit in ColdFire. I finally have a working fix which Ray has just released over at RIAForge. I strongly recommend that all ColdFire users download and install the latest version (1.003) as soon as possible.

Problems with CF 8's Generated Keys Feature

So you may have read about CF 8's new ability to return generated keys. For SQL Server 2000 and greater this means that the driver attempts append the SELECT SCOPE_IDENTITY() statement to end of insert statements. If you want to get an idea of how this is done you can take a look at the source for the jTDS JDBC driver. While the jTDS driver isn't what ships with ColdFusion, you can bet that CF's SQL Server driver from DataDirect is doing something similar. In fact you can actually confirm this using SQL Profiler.

[More]

Spry AutoSuggest With Multiple Parameters

When loading datasets from the server for for the Spry AutoSugget widget, Spry passes the value of the search field as a parameter to the dataset URL. This works fine, but what if the suggestions you want to provide are based on a combination of form fields?

To give you a better of idea of what I mean, here is an example of a search form I was working on earlier today: (Note: this form doesn't work.)

Find users within of the following :

I wanted to provide suggestions for the search term, but I wanted to limit those suggestions to only the country (U.S. or Canada) and type (City or Postal Code) selected. So if a user selects U.S. Cities they should only get U.S cities as suggestions, no Canadian cities or postal codes of any kind. This turned out to be fairly easy but I though I'd share my approach in case others are interested.

Basically what I needed to do is append multiple parameters to the dataset URL. To accomplish this I added a new function to the Spry AugoSuggest widget named addReplaceParams:

Spry.Widget.AutoSuggest.prototype.addReplaceParams = function(params)
{
   
   var ds = this.dataset;
   ds.cancelLoadData();
   ds.useCache = false;
   
   this.setValue('');
   this.showSuggestions(false);
      
   var url = ds.url;
   
   for(var i=0; i < params.length; i++) {   
      url = Spry.Widget.Utils.addReplaceParam(url, params[i].param, params[i].value);   
   }      
   
   ds.setURL(url);
   ds.loadData();
   
};
In a nutshell this function clears the search term, hides suggestions and updates the AutoSuggest's dataset URL using an array of parameters passed to the function. The parameters are defined as simple JavaScript objects with two keys: param which is the name of the URL parameter, and value which is the value of the URL parameter. It does the actual parameter additon/replacement using the Spry.Widget.Utils.addReplaceParam() function. To update the URL using this function I wrote another function which I use as the onChange event handler for the country and type select elements.
function updateDsURL(f){
   
   var country = f.radiusCountry[f.radiusCountry.selectedIndex].value;
   var type = f.radiusType[f.radiusType.selectedIndex].value;
   
   var params = [];
   params[0] = {param:'radiusCountry',value:country};
   params[1] = {param:'radiusType',value:type};
   
   theSuggest.addReplaceParams(params);   
};

Putting it all together this is what it looks like:

<html>
<head>
<script language="JavaScript" type="text/javascript" src="includes/xpath.js"></script>
<script language="JavaScript" type="text/javascript" src="includes/SpryData.js"></script>
<script language="JavaScript" type="text/javascript" src="includes/SpryAutoSuggest.js"></script>
<link href="includes/SpryAutoSuggest.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
var ds1 = new Spry.Data.XMLDataSet("/suggestions.cfm","radiusvalues/radiusvalue");

function updateDsURL(f){
   
   var country = f.cboRadiusCountry[f.cboRadiusCountry.selectedIndex].value;
   var type = f.cboRadiusType[f.cboRadiusType.selectedIndex].value;
   
   var params = [];
   params[0] = {param:'radiusCountry',value:country};
   params[1] = {param:'radiusType',value:type};
   
   theSuggest.addReplaceParams(params);   
};


Spry.Widget.AutoSuggest.prototype.addReplaceParams = function(params)
{
   
   var ds = this.dataset;
   ds.cancelLoadData();
   ds.useCache = false;
   
   this.setValue('');
   this.showSuggestions(false);
      
   var url = ds.url;
   
   for(var i=0; i < params.length; i++) {   
      url = Spry.Widget.Utils.addReplaceParam(url, params[i].param, params[i].value);   
   }      
   
   ds.setURL(url);
   ds.loadData();
   
};
</script>
</head>

<body>
<form>
<p>
Find candidates within
<select name="radius">
   <option value="0" selected>Any Distance</option>
   <option value="1">1 mile</option>
   <option value="2">2 miles</option>
   <option value="3">3 miles</option>
   <option value="4">4 miles</option>
   <option value="5">5 miles</option>
   <option value="10">10 miles</option>
</select>
of the following
<select name="radiusCountry" onChange="updateDsURL(this.form);">
   <option value="U" selected>U.S.</option>
   <option value="C">Canadian</option>
   <option value="B">U.S. or Canadian</option>
</select>
<select name="radiusType" onChange="updateDsURL(this.form);">
   <option value="City"selected>City</option>
   <option value="Zip">Postal Code</option>
</select>:
</p>

<div id="mySuggest">
<input type="text" name="radiusValue"/>
<div id="resultsDIV" spry:region="ds1">
<ul>
<li spry:repeat="ds1" spry:suggest="{radiusvalue}">{radiusvalue}</li>
</ul>
</div>
</div>
<script type="text/javascript">
   var theSuggest = new Spry.Widget.AutoSuggest("mySuggest","resultsDIV", "ds1","name",{minCharsType:3, loadFromServer:true, urlParam:'filter'});
</script>

</form>
</body>
</html>

You may ask why two functions? Well, I thought this is something I may want to use again so I made the Spry.Widget.AutoSuggest.addReplaceParams() function fairly generic. For this example I included the function in the inline script block, but if I use it enough I'll probably end up putting it in my AutoSuggest.js file.

OK, that's one down...

ColdFire 1.002

Today Ray and I released ColdFire 1.002 which fixes a few minor issues with JSON encoding. If you were having problems with the variables feature of ColdFire this update may fix your issue. Be sure to update both the Firefox extension and coldfire.cfm debugging template. You can get both via the download at RIAForge.

We have also been discussing upcoming features so if there is something you would really like to see be sure to let us know via the RIAForge site.

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.