Sunday, March 21, 2010    
Home My Books Blog ColdFusion About Me Back    

Calendar
<< Jul 2007 >>
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Search

Categories
 • Acrobat (3) [RSS]
 • Adobe (90) [RSS]
 • AdobeMAX06 (45) [RSS]
 • AdobeMAX07 (59) [RSS]
 • AdobeMAX08 (66) [RSS]
 • AdobeMAX09 (39) [RSS]
 • AdobeMAX10 (1) [RSS]
 • AIR (219) [RSS]
 • Appearances (191) [RSS]
 • Books (72) [RSS]
 • CFEclipse (15) [RSS]
 • ColdFusion (1381) [RSS]
 • Data Services (34) [RSS]
 • Fish Tank (5) [RSS]
 • Flash (197) [RSS]
 • Flex (498) [RSS]
 • Home Automation (5) [RSS]
 • Jobs (116) [RSS]
 • JRun (14) [RSS]
 • Labs (43) [RSS]
 • LiveCycle (34) [RSS]
 • MAX (232) [RSS]
 • Mobile (120) [RSS]
 • Regular Expressions (17) [RSS]
 • RIA (21) [RSS]
 • SQL (40) [RSS]
 • Stuff (536) [RSS]
 • Tips (CF Studio) (80) [RSS]
 • Tips (CF) (795) [RSS]
 • Tips (Dreamweaver) (91) [RSS]
 • Tips (Flex Builder) (2) [RSS]
 • Using CF (162) [RSS]

Other BLOGs
 • Charlie Arehart
 • Lee Brimelow
 • Ray Camden
 • Christophe Coenraets
 • Sean Corfield
 • Mihai Corlan
 • Cornel Creanga
 • Mark Doherty
 • John Dowdell
 • Danny Dura
 • Enrique Duvos
 • Steven Erat
 • Kevin Hoyt
 • Serge Jespers
 • Adam Lehman
 • Duane Nickull
 • Miti Pricope
 • Andrew Shorten
 • Ryan Stewart
 • James Ward
 • Greg Wilson
 • Full As A Goog

RSS Feeds
 • Feed
 • Subscribe

Join my mailing list and find out about new books and other topics of interest.

Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.

Viewing By Entry / Main
July 17, 2007

Last Minute ColdFusion Ajax Enhancements

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:

<!--- Lookup used for auto suggest --->
<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">
    SELECT artname
    FROM art
    WHERE UCase(artname) LIKE Ucase('#ARGUMENTS.search#%')
    ORDER BY artname
    </cfquery>

    <!--- And return it --->
    <cfreturn ValueList(result.artname)>
</cffunction>

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:

<cfselect name="mediaid"
        bind="cfc:art.getMedia()"
        bindonload="true"
        value="MediaID"
        display="MediaType" />

These are great little enhancements, and I am glad the team was able to get them in just in time.

TrackBacks
CF 8 Ajax with CFSELECT BIND
love the new AJAX functionality in ColdFusion 8, but I am running into problems using it.

As mentioned in Ben Forta's blog you can use the BIND= attribute on a CFSELECT tag to populate the data from a CFC using AJAX.

The problem I had was that even using Ben's samples I could not get the data to populate. After alot of tinkering I finally got it to work by remove the onRequest() method from Application.cfc. Why this affects this functionality is a mystery to me. Really for the application I'm working on it's not a big problem but on other projects it could be.

My second part of the problem is that I have a cfc directory that is OUTSIDE of the application's root directory. For example:

/website_root

/components

/images

Then I map /cacfc to /components and reference my cfc's by prepending cacfc to the component IE. cacfc.database.data. This works great as I can share components among applications easily enough. But when I call the cfc with the bind attribute of the CFSELECT, ColdFusion looks for the cfc in the root directory. Here's an example:
Tracked by Scratty.com | Tracked on 1/30/08 10:41 AM
CF 8 Ajax with CFSELECT BIND
I love the new AJAX functionality in ColdFusion 8, but I am running into problems using it.

As mentioned in Ben Forta’s blog you can use the BIND= attribute on a CFSELECT tag to populate the data from a CFC using AJAX.

The problem I had was that even using Ben’s samples I could not get the data to populate. After alot of tinkering I finally got it to work by remove the onRequest() method from Application.cfc. Why this affects this functionality is a mystery to me. Really for the application I’m working on it’s not a big problem but on other projects it could be.

My second part of the problem is that I have a cfc directory that is OUTSIDE of the application’s root directory. For example:

/website_root
/components
/images

Then I map /cacfc to /components and reference my cfc’s by prepending cacfc to the component IE. cacfc.database.data. This works great as I can share components among applications easily enough. But when I call the cfc with the bind attribute of the CFSELECT, ColdFusion looks for the cfc in the root
Tracked by Scratty.com | Tracked on 4/15/09 10:46 PM

No trackback URL. Trackbacks are only allowed via interactive form.

Comments
I know this sounds elementary but make sure that your path to your grid is set correctly.
<cfajaxproxy cfc="[mypath].QuotesGrid" jsclassname="jQuotesGrid" />
how I resolved the "...not caught" issue.
# Posted By Guillermo | 10/22/09 10:53 AM
I am also having the exception thrown not caught error. I have addcfm and getGamecfc inside another folder called manager in my site root folder.
When I moved my CFC file into the server root, the feature worked fine. How can I make it work inside another directory, though?
# Posted By Mohamad | 12/5/09 3:36 PM

  © Copyright 1997-2009 Ben Forta, All Rights Reserved