OpenBD / openbd-core

The original open source Java powered GPL CFML runtime engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CFAjaxproxy not starting from root.

minifiredragon opened this issue · comments

CFInvoke properly starts from root when used. However, CFAjaxproxy starts from the directory it is in and never goes out to root. I am not sure how I can put a code sample in because there is no way to show that it is not working correctly inside the code block, as it is not the code example that is the issue.

CFML Document:

Javascript side:
sCFC = new stampsClass();

CFML Document location:
/public_html/amazon/stamps.cfm (example)

CFC location:
/cfc/stamps.cfc

When page is run, CJAjaxproxy fails:

Type Application
Detail A request was made to a resource that could not be located
Missing File cfc.stampss
Tag Context CFAJAXPROXY (/public_html/amazon/stamps.cfm, Line=7, Column=1)
Source

4 :
5 : <title>Order Fulfillment</title>
6 :
7 :

But if you use cfinvoke component="cfc.stamps" it will function as it should.

@minifiredragon That follows the Adobe implementation, but I added a new optional parameter called siteroot which will let you start from there instead.

So just use siteroot="true" and it'll append / to the path and let you hit CFCs from the root on up.

Thank you. I do have 1 question though, with out this, how does one get out of the directory they are in and access a cfc in another directory? I have been writing cffunctions that use cfinvoke to get to a different folder since all I can do is go deeper in the current directory and nothing else.

RPC endpoints are super easy to work with, but cfajaxproxy makes it even simpler.

Without it you'd have to not use cfajaxproxy but directly call the CFC and function like so:

http://www.AwesomeSite.com/components/coolComponent.cfc?method=myFunction&mydata=123

Assuming your component lives under the subfolder components.

Specify returnformat="JSON" in your function and you're all set.

Example:

Save to your root directory as mycomp.cfc and you can call it with "/mycomp.cfc?method=getPosts&authorId=123" from any AJAX client.

component {
  remote struct function getPosts( required numeric authorId ) returnformat="JSON" {
    try {
      var params = [ { value: argumetns.authorId, cfsqltype: "cf_sql_integer" } ];
      var data = queryRun( "yourdsn", "SELECT id, body FROM posts WHERE authorId = ?", params );
      return { success: true, data: queryToArray( data ) };
      
    } catch( any e ) {
      return { success: false, error: e.message, details: e };
    }
  }
}

I think this can be closed now