Difference between revisions of "Ajax Proxy"

From ADF Docs
Jump to: navigation, search
(Example)
(Example)
Line 12: Line 12:
  
 
== Example==
 
== Example==
<code>
+
<pre>
 
jQuery.get("#application.ADF.ajaxProxy#",
 
jQuery.get("#application.ADF.ajaxProxy#",
 
   { bean: "CSData_1_0",
 
   { bean: "CSData_1_0",
Line 19: Line 19:
 
     returnFormat: "json" },  
 
     returnFormat: "json" },  
 
     function( results ) ...
 
     function( results ) ...
};
+
});
</code>
+
</pre>
  
 
== Configuring==
 
== Configuring==

Revision as of 16:29, 18 December 2009

Overview

Ajax Proxy is a CFM file located in the /_cs_apps/ directory of your site (copy from the /ADF/core/site-sample/) 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 essentially 2 fold:

  1. Control security access to the methods within the ADF
  2. Load the site application space so that library and app calls can 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

jQuery.get("#application.ADF.ajaxProxy#",
  { bean: "CSData_1_0",
     method: "getSubsiteStruct",
     subsiteURL: "#request.subsite.url#",
     returnFormat: "json" }, 
    function( results ) ...
});

Configuring

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:

setAjaxProxyURL("#request.site.csAppsWebURL#ajaxProxy.cfm");

after the "loadSite()" call

Make sure you 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.

You should also become familiar with the CS Security v1 component. If your method preforms potentially dangerous actions, you may also want to check to ensure that the call is being conducted by a licensed contributor or a site admin.