A while back I posted examples of using ColdFusion 8 Ajax support to power an auto-suggest control and related <CFSELECT> controls. Both examples required that the back-end CFC methods create arrays (1 dimension for the former, 2 dimensions for the latter). And I pointed out that I hoped we'd be able to tighten that syntax before we ship.
Well, we did. In the final CF8, the CFC method bound to auto-suggest can return a simple list (a string), and the CFC bound to a <CFSELECT> can return a query. This makes the code orders of magnitude simpler. I am not going to update those entries just yet (as these enhancements won't work with the public beta), but ...
The CFC method to power an auto-suggest could be simplified like this:
<cffunction name="lookupArt" access="remote" returntype="string">
<cfargument name="search" type="any" required="false" default="">
<!--- Define variables --->
<cfset var result="">
<!--- Do search --->
<cfquery datasource="#THIS.dsn#" name="result">
WHERE UCase(artname) LIKE Ucase('#ARGUMENTS.search#%')
ORDER BY artname
<!--- And return it --->
The CFC method to power a <CFSELECT> could now just return a query. And the <CFSELECT> control would then use the existing VALUE and DISPLAY attributes to specify the query columns to be used, like this:
These are great little enhancements, and I am glad the team was able to get them in just in time.