Difference between revisions of "Ajax Proxy"

From ADF Docs
Jump to: navigation, search
(Example)
 
Line 27: Line 27:
 
</pre>
 
</pre>
  
== Configuring==
+
== Moving Ajax Proxy ==
To start using the Ajax Proxy, be sure to copy the ajaxProxy.cfm located in /ADF/core/site-sample/ into your sites /_cs_apps/ directory.  Additionally, make sure that in your ADF.cfc (located in your /_cs_apps/ directory) you have the following line in your init() method:
+
As a part of the installation of the ADF you were required to copy the ajaxProxy.cfm located in /ADF/core/site-sample/ into your sites /_cs_apps/ directory.  Additionally, you copied ADF.cfc (located in your /_cs_apps/ directory) into the same directory (/_cs_apps).
 +
 
 +
If you would like to move the Ajax Proxy (say into the root of your site) you must:
 +
 
 +
# Move the ajaxProxy.cfm file into the root of your site
 +
# Open ADF.cfc (from the /_cs_apps/ directory in your site) and modify the following line:
 +
 
 
  setAjaxProxyURL("#request.site.csAppsWebURL#ajaxProxy.cfm");
 
  setAjaxProxyURL("#request.site.csAppsWebURL#ajaxProxy.cfm");
  
After the "loadSite()" call, make sure you [[Reset ADF|Reset your Site ADF]].
+
change to:
 +
 
 +
setAjaxProxyURL("ajaxProxy.cfm");
 +
 
 +
# [[Reset ADF|Reset your Site ADF]].
  
 
== Security ==
 
== Security ==

Latest revision as of 00:35, 8 March 2010

Overview

Ajax Proxy is a CFM file located in the /_cs_apps/ directory of your site (Note: this file was copied from the /ADF/core/site-sample/ directory as a part of installation) directory. The concept of the Proxy is to have a single endpoint for all ajax calls into the ADF library and/or Apps that are built. The goal with this single endpoint is two-fold:

  1. Control security access to the methods within the ADF
  2. Load the site application space so library and app calls have site level context

Usage

To use the Ajax Proxy in a jQuery get/post call, do the following:

  1. URL to call is #application.ADF.ajaxProxy#
  2. Add in the name of the bean you want to call
  3. Add in the name of the method within that bean you want to call
  4. Add any other parameters (which will be passed into your function)

Example

If you wanted to call the "getSubsiteStruct()" method (returns an array of subsite data) in the csData_1_0 component you would do the following:

jQuery.get("#application.ADF.ajaxProxy#",
  { bean: "CSData_1_0",
     method: "getSubsiteStruct",
     subsiteURL: "#request.subsite.url#",
     returnFormat: "json" }, 
    function( results ) ...
});
Note: notice how the "bean" (e.g cfc or component) requires the version

Moving Ajax Proxy

As a part of the installation of the ADF you were required to copy the ajaxProxy.cfm located in /ADF/core/site-sample/ into your sites /_cs_apps/ directory. Additionally, you copied ADF.cfc (located in your /_cs_apps/ directory) into the same directory (/_cs_apps).

If you would like to move the Ajax Proxy (say into the root of your site) you must:

  1. Move the ajaxProxy.cfm file into the root of your site
  2. Open ADF.cfc (from the /_cs_apps/ directory in your site) and modify the following line:
setAjaxProxyURL("#request.site.csAppsWebURL#ajaxProxy.cfm");

change to:

setAjaxProxyURL("ajaxProxy.cfm");
  1. Reset your Site ADF.

Security

By default all methods within an application or the ADF library are locked down. To make a method available you must add it to either your applications Proxy White List (recommended) or the global Proxy White List.

If your method performs potentially dangerous actions, you may also want to verify the call is being conducted by a licensed contributor or a site admin.