Fun with CFAJAXPROXY on ColdFusion 11

In the course of moving an application from ColdFusion 8 to ColdFusion 11, I came across some strange behavior caused by the CFAJAXPROXY tag.

In CF8, a particular CFCOMPONENT called ProjectBeanService had proxies set up for its methods in the rendered JavaScript like this:

var _cf_ProjectBeanService = ColdFusion.AjaxProxy.init('/components/ProjectBeanService.cfc', 'ProjectBeanService');
_cf_ProjectBeanService.prototype.get = function(sPropertyName, sBeanType, nID, sSection, nRevision) { return ColdFusion.AjaxProxy.invoke(this, "get",  {sPropertyName:sPropertyName, sBeanType:sBeanType, nID:nID, sSection:sSection, nRevision:nRevision});};
_cf_ProjectBeanService.prototype.getAll = function(sBeanType, nID, sSection, nRevision) { return ColdFusion.AjaxProxy.invoke(this, "getAll", {sBeanType:sBeanType, nID:nID, sSection:sSection, nRevision:nRevision});};
_cf_ProjectBeanService.prototype.set = function(sPropertyName, oPropertyValue, sBeanType, nID, sSection, nRevision) { return ColdFusion.AjaxProxy.invoke(this, "set", {sPropertyName:sPropertyName, oPropertyValue:oPropertyValue, sBeanType:sBeanType, nID:nID, sSection:sSection, nRevision:nRevision});};

However, in CF11, more proxies were created:


This made no sense to me, as the ProjectBeanService class only had the three methods declared that were proxied in CF8. I looked at the ProjectBeanService.cfc file:















I saw that this class extended another class, AjaxBeanService:


















This class contained the methods that were showing up in the rendered code on CF11.

I found that at least part of this issue was most certainly a bug in CF8 that had been corrected in CF9. In CF8, a child class apparently did not have access to the methods of the parent class via CFAJAXPROXY if the parent class methods were marked as having “remote” access. No longer, in CF9 and subsequent versions. Source (in comments): Ask a Jedi: ColdFusion Ajax example of retrieving fields of data (2)

However, that did not explain why the parent class method proxies were being rendered AFTER the child class methods, thus preventing the child from overriding the parent class methods.

So far, the only fix I have is to mark the parent methods access attributes as “public” rather than “remote”. This seems like a poor way to do it, and may yet have unintended consequences, but without writing new JavaScript to avoid the use of CFAJAXPROXY, this may be the best solution for now.

Incidentally, an article on doing that very thing is here, in case anyone needs it: Creating A Remote AJAX Proxy In Javascript Without ColdFusion 8’s CFAjaxProxy

If anyone has any better suggestions on how to fix this problem, I’ve submitted it as a question on Stack Overflow.

my Stack Overflow question

Loading Facebook Comments ...