0

cfAjaxProxy and Mach-II

ColdFusion 8, Mach-II

Here's an easy way to use cfAjaxProxy with a Mach-II application.

First I created a new cfc that extends Application.cfc to gain access to all of the Mach-II features.

Then add a function with access="remote" and list all of the arguments (cfajaxproxy requires all arguments be defined). Next set all the arguments to the form or url scope so that Mach-II can read them. Finally call handleRequest().

<cfcomponent output="false" extends="Application">
<cffunction name="getData" access="remote" output="true" hint="">
	<cfargument name="artistID" default="">
	<cfargument name="artistName" default="">
	<cfset url.event = "user.edit">
	<cfset url.artistID = arguments.artistID>
	<cfset url.artistName = arguments.artistName>
	<cfset handleRequest()>
</cffunction>
</cfcomponent>

I'm sure there are cleaner ways but this works and allows easy use of the great cfAjaxProxy tag in a Mach-II application.

 
Cool idea Sam, and timely for me. I am doing a presentation this week on some of the CF8 ajax stuff and will include this example if you don't mind. I will be sure to give credit. :)
 
posted 529 days ago
View Replies (1) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
samfarmer said:
 
Go for it...no problem at all.
 
posted 529 days ago
Add Comment Reply to: this comment OR this thread
 
 
Sam, is the basic idea behind this that your views would then generate the appropriate JSON string to pass back? I am having a mental disconnect on the "return" part of this process.
 
posted 526 days ago
View Replies (2) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
samfarmer said:
 
Yes. So the request would work just like a standard Mach-II request.
 
posted 526 days ago
Add Comment Reply to: this comment OR this thread
 
 
OK, allow me one more noob-ish question, but would I need to do the JSON serialization "by hand" or is this still automgically handled by cfaxajproxy?
 
posted 526 days ago
Add Comment Reply to: this comment OR this thread
 
WOW gold said:
 
 
posted 213 days ago
Add Comment Reply to: this comment OR this thread
 

Search

Twitter
You should follow me on Twitter here
About Me
I am a 34-year old Web Developer specializing in ColdFusion. I live and work in downtown Washington, DC with my wife and two daughters. Read more About Me

2007 CFeMmy Best Newcommer winner
As voted on by fellow CF Bloggers.
CFinNC - Carolina ColdFusion / Flex / Air Conference - Oct 17-18, 2009