Classes (1)  /  ColdFusion (14)  /  ColdFusion Jobs (2)  /  General (6)  /  JQuery (7)  /  Quick and Dirty (3)  / 
Search Blog

 

Archives
RSS

 

 

 

Adobe Community Expert in ColdFusion

 

Adobe Ceritfied Instructor

 

CTT+ Certified Technical Trainer

 

Hosted By:

Alurium Hosting

Powered by BlogCFM v1.14

21 March 2010
cfajaxproxy and JQuery
The agnostic nature of cfajaxproxy
Untitled Document

The agnostic nature of cfajaxproxy.

I always thought that cfajaxproxy was inexorably tied to the Ajax functions built into ColdFusion.. I recently found out that
I was wrong.

CFAjaxproxy is used to create a javascript proxy of a ColdFusion Component (cfc) for use in the web client. This means any javascript,
not just ColdFusion based AJAX components.

Lets take the AJAX post code from my last post and see how it would work with cfajaxproxy.

This is the original code: It's calling action pages to execute ColdFusion components.


$("#getTOByWeek").live("click", function(){
   $.ajax({
         type:"post",
         url:"webapps/hr/admin/actions/act_adminHR_Handler.cfm",
        data:$("#toByWeek").serialize(),
        cache:"false",
        success: function(){
            $("#content-box").load("webapps/hr/admin/display/dsp_TOList.cfm");
        },
       error: function(){
           alert("data");
       }
   });
   return false;
});

If I use cfajaxproxy it would look something like this, to achieve the same functionality

<cfajaxproxy cfc = "CFC name" jsclassname = "JavaScript proxy class name">

The CFC property instantiates the entire component, using dot notation (com.foo.bar.component), jsclassname is the name that is given to the function
inside javascript:

<cfajaxproxy cfc="hr.cfc.hr_dao" jsclassname="hr_dao">

This gives me a javascript representation of my hr_dao.cfc that can be used in any javascript case.
//instantiate the ColdFusion Function
<cfajaxproxy cfc="hr.cfc.hr_dao" jsclassname="hr_dao">

//capture the click event
<script>
$("#getTOByWeek").click(function(objEvent){
         //call the ColdFusion method directly

         hr_dao.getTimeOffStatus(objEvent);
        //trigger the success function based on return
       return false;
      });
<script>

Posted by admin at 5:50 PM | Link | 0 comments

No comments found.

Post a comment (login required)

 

© 2011 Scott Stewart / SSTWebworks
Design by Contented Designs