javascriptcoldfusioncfcopenbd

Relative/Absolute CFC path in Open BlueDragon


I'm trying to migrate an existing ColdFusion codebase from Adobe CF8 to OpenBD. My files include something like this:

/cfc/one.cfc
/cfc/two.cfc

/app/page.cfm

In CF8 I had a mapping from 'cfc' to '/cfc', and in page.cfm I had:

<cfajaxproxy cfc="cfc.one" jsclassname="oneCfc">
<cfajaxproxy cfc="cfc.two" jsclassname="twoCfc">

and then in Javascript I could call the CFC using:

var c = new oneCfc();

...and life was good.


Under Open BD (v2.0.3b) however, I can't seem to call the CFC functions from Javascript. The proxy is declared as before, and I can create the object in Javascript, but when I try to call a function I get the following error in my browser dev tools:

POST http://127.0.0.1:8080/app/cfc/one.cfc 404 (Not Found) 

It appears to be using a relative path in Javascript when it tries to call the function, even though it's already got the object created.

The CFC is valid according to OpenBD (I can browse to ./cfc/one.cfc?wsdl, and I can call functions on it using ./cfc/one.cfc?method=getData etc). It doesn't seem to matter whether I have a mapping defined in OpenBD or not.

The one workaround that seems to work is having the CFC in the same function as the calling CFM file, but this isn't a very good solution when I want to reuse the CFC code from many different pages.

Has anyone got CFCs in other directories working under OpenBD?


Solution

  • For future reference: this problem was resolved (more or less) in OpenBD 3.0, released early March 2013.

    In 3.0 the code that creates the AJAX proxy .js file was modified to include the lines:

    javascript.append( " this.remoteCFC = '" );
    javascript.append( CFC.replace('.', '/') );
    javascript.append( ".cfc';\r\n" );
    

    While it still does not take into account any server-side mappings, it at least allows you to reference a path that is not a child of the current .cfm page:

    <cfajaxproxy cfc=".cfc.one" jsclassname="cfcOne">
    

    (note the leading ., which is replaced with a / by OpenBD. In previous versions of OpenBD this would generate an error)