Skip navigation
Currently Being Moderated

onRequestStart in CF8 is a bug?

Oct 14, 2013 4:53 PM

I'm creating a cascading select drop dwon with ColdFusion ajax from Ben Forta: elated-Selects

But it is not entirely working. The first drop down works and shows the countries in a drop down but the second drop down doesn't show the related States!

I did some googling and found out that this is a problem of CF8 (?) because I'm using Application.cfc

To get around this, I found Ray Camden's blog that said the following:


There is a way around it. Sean Corfield has a nice little work around that involves adding the following code to your onRequestStart (not onRequest, but onRequestStart):

1<cfif listlast(arguments.thePage,".") is "cfc">

2<cfset StructDelete(this, "onRequest") />

3<cfset StructDelete(variables,"onRequest")/>



I already put this code on my OnRequest function in my Application.cfc but I don't quite understand what is .thePage actually mean??

I replaced argument.thePage with argument.Name_of_My_cfc which is AjaxCountryProvince:

But simply added this code like this (see below), it is still not working. Please help!!


<cffunction name="onRequestStart" returnType="string" output="false">


    <cfif ListLast(arguments.AjaxCountryProvince,".") is "cfc">

          <cfset StructDelete(this, "onRequest") />

          <cfset StructDelete(variables,"onRequest")/>



     <cfset request.mySecretKey = application.mySecretKey />

     <cfset request.algorithm = "AES" />

     <cfset request.encoding = "hex" />




Please advice, I've been stucked with this functionality for two weeks

  • Currently Being Moderated
    Oct 14, 2013 5:10 PM   in reply to BYJ_wntrsnt

    There is a little piece of information missing from Ray's blog post.  The onRequestStart() method requires an argument through which ColdFusion can pass the name of the template being called.  So you need to add this line right below the <cffunction> tag:

    <cfargument name="thePage" type="string" required="true">


    Then change the <cfif> tag to what was in the blog post:

    <cfif listlast(arguments.thePage,".") is "cfc">


    So now what the onRequestStart() code is doing is examining the name of the template being called, and if it ends in "cfc", deletes the onRequest() method from the instance of application.cfc being used to process this AJAX request.



    -Carl V.

    Mark as:
  • Currently Being Moderated
    Oct 15, 2013 8:07 AM   in reply to BYJ_wntrsnt

    My guess is that since you the returnType on your function is set to "array", it is trying to send a native ColdFusion array back to the JavaScript code generated by the <CFSELECT> tag.  I have'nt used <CFSELECT>, or the binding to CFC that is built into it, so I can't say with authority that this is definitely your problem.  You might use the debugging tools in Chrome or Firefox to examine the AJAX data being returned by your CFCs and see if they are in the right format.


    -Carl V.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points