Skip to main content
Inspiring
October 1, 2010
Answered

cf 9: cf ajax not compatible with Application.cfc?

  • October 1, 2010
  • 1 reply
  • 3207 views

Hello,

Background:
I use the Application.cfc framework.  I like the onMissingTemplate, onError, and other functionality that it offers.  I've been working with Application.cfc since CF 7.

I started working on a project that required CF 9.  I wanted to use a cfgrid control and also some of the ajax features for a form.  I ran into problems with cfgrid right away.  The problem was with the bind attribute calling a remote funciton in a CFC.  Here is a sample of the error message that I'm able to get using the ?cfdebug=1 URL parameter:

JSON parsing failure: Expected '"' at character 2:'&' in {"page":1,"pageSize":10,"sortColumn":"","sortDirection":"ASC"}

Notice that somehow all of the double quote characters are getting transposed to be html encoded values """.  This is what the JSON parser is complaining about.

I switched tasks and started working on a simple form that used an autosuggest feature.  Then as I started testing this form, I ran into almost the exact same error:

JSON parsing failure: Expected '"' at character 2:'&' in {"vcSuggestValue":"5"}

After tweaking so many settings without any success, I decided to rename all my Application.cfc files and create a basic Application.cfm file.  It worked!

Next I tried to find out what was broken in my Application.cfc file as I thought that perhaps I had something screwed up.  I ended up down to a file like this:


<cfcomponent>
    <cfset this.name = "abc_admin">
    <cfset variables.dsn = "abc">

<cffunction name="onRequestStart" output="true" returntype="boolean" hint="Runs when a request starts">
    <cfargument name="targetPage" type="string" required="yes" hint="Path from the web root to the requested page." />


    <cfset request.dsn = variables.dsn>
    <cfset request.vcProductName = "abc.org">


    <cfreturn true />
</cffunction>
</cfcomponent>

As you can see the above Application.cfc file has almost nothing in it besides a couple of names and a datasource definition.  The cfgrid and autosuggest <cfinput> tag still do not work.

I took my project and moved it to a CF 8 server where these features worked fine.

I have tried to use Application.cfc on a CF 9 server running on IIS 6 and IIS 7.5.  Both of them fail so I do not believe that it is caused by the web server.

At this point I'm inclined to think that Application.cfc is broken all of the CF ajax features for ColdFusion 9.  If you have a solution to this problem, please reply to this message with an answer.  If you have ColdFusion 9, please try a simple autosuggest field on a form and see if it works with an Application.cfc based web site, please reply with your results.

Best regards,
Scott Jibben

    This topic has been closed for replies.
    Correct answer Adam Cameron.

    You probably need to add a onCfcRequest() handler to your Application.cfc file...

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe821657cd7d6f83f6daaa733122cf6931bb-8000.html

    --

    Adam

    1 reply

    Adam Cameron.Correct answer
    Inspiring
    October 1, 2010

    You probably need to add a onCfcRequest() handler to your Application.cfc file...

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe821657cd7d6f83f6daaa733122cf6931bb-8000.html

    --

    Adam

    sjibbenAuthor
    Inspiring
    October 1, 2010

    Well, that does work.  Odd that the default onCFCRequest function doesn't work.

    thanks!

    Inspiring
    October 1, 2010

    Well, that does work.  [...] thanks!

    No probs.

    Odd that the default onCFCRequest function doesn't work.

    Sorry, don't follow..?

    --

    Adam