So I am pretty much following this suggested link: 

objectorientedcoldfusion.org 

Correct? 

----- Original Message -----
From: "Matthew Woodward" <[email protected]> 
To: [email protected] 
Sent: Saturday, March 3, 2012 6:30:14 PM 
Subject: Re: [OpenBD] Doing Ajax via OpenBD without a framework 

On Thu, Mar 1, 2012 at 10:33 AM, < [email protected] > wrote: 





I understand that part, but I am not sure how to go about it. 





Create a CFC that has access="remote" wrapper methods for calls to other CFCs. 
It's no more complicated than that. The only question is where you want to put 
your other objects you're calling (inside the remote facade, in the application 
scope, instantiate inside your facade object as needed ...). 


I'll just show an example that will assume for the sake of argument that you're 
going to put the CFCs your remote facade will use in the application scope. 


In Application.cfc you'd do something like: 


<cfcomponent displayname="Application" output="false"> 
<cffunction name="onApplicationStart" access="public" output="false" 
returntype="boolean"> 
<cfset Application.cfc2 = CreateObject("CFC2") /> 


<cfreturn true /> 
</cffunction> 
</cfcomponent> 


Note that assumes CFC2.cfc is in the root of your application, but if it's 
elsewhere just use dot notation (the bug with the dot notation you uncovered 
only impacts CFAJAXPROXY, not instantiating CFCs in other ways). 


Facade CFC would be something like: 


<cfcomponent displayname="Remote Facade" output="false"> 
<cffunction name="getFoo" access="remote" returntype="string"> 
<cfreturn Application.cfc2.getFoo() /> 
</cffunction> 
</cfcomponent> 


CFC2 in the application scope would be what actually returns the data: 


<cfcomponent displayname="CFC2" output="false"> 
<cffunction name="getFoo" access="public" returntype="string"> 
<cfreturn "Hello from CFC2!" /> 
</cffunction> 
</cfcomponent> 


And as I said you don't *have* to put the other CFCs in the application scope, 
that would just depend on what makes sense for your needs. 


The other nice thing about this approach is if you're using CFC methods in 
another way or returning the data in another format for non-AJAX calls, the 
remote facade can massage the data as needed for use via AJAX calls. 


Hope that helps. -- 
Matthew Woodward 
[email protected] 
http://blog.mattwoodward.com 
identi.ca / Twitter: @mpwoodward 

Please do not send me proprietary file formats such as Word, PowerPoint, etc. 
as attachments. 
http://www.gnu.org/philosophy/no-word-attachments.html 


-- 
online documentation: http://openbd.org/manual/ 
google+ hints/tips: https://plus.google.com/115990347459711259462 
http://groups.google.com/group/openbd?hl=en 

-- 
online documentation: http://openbd.org/manual/
   google+ hints/tips: https://plus.google.com/115990347459711259462
     http://groups.google.com/group/openbd?hl=en

Reply via email to