<rss version="2.0">
			<channel>
			<title>RIA CFML Flex Flash</title>
			<link>http://www.cfcdeveloper.com/index.cfm</link>
			<description>Adobe RIA Development</description>
			<language>en-us</language>
			<pubDate>Wed, 08 Sep 2010 06:51:50 -0700</pubDate>
			<lastBuildDate>Tue, 20 Oct 2009 07:10:00 -0700</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>clint317@cfcdeveloper.com</managingEditor>
			<webMaster>clint317@cfcdeveloper.com</webMaster>
			
			
			
			
			
			<item>
				<title>Using do as the event name in Coldbox, don&apos;t.</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/10/20/Using-do-as-the-event-name-in-Coldbox-dont</link>
				<description>
				
				It took me a day to figure this out, live and learn right. I used &apos;do&apos; as the event name in one of my Coldbox applications as opposed to &apos;event&apos; given as the default. If you&apos;re considering what to name your events in Coldbox, don&apos;t. Just use the default &apos;event&apos; name given. I was just trying to be unique but it backfired.

The &apos;do&apos; term is a reserved keyword in Flex, ActionScript actually. The lesson I got from this is to not ever use any keywords from any language for which you may mix. In this case I was using Flash remoting from my Flex application to to fire remote ColdFusion functions from the Coldbox framework remote proxy.

Here is the code I was using in my Flex actionscript. Notice the &apos;event&apos; object param passed to the proxy process function, you can&apos;t use &apos;do&apos;, well technically you can but don&apos;t because it won&apos;t work.

&lt;code&gt;
private function authenticateClient():void {
	var cProxy:RemoteObject = getColdBoxProxy();
	cProxy.addEventListener(FaultEvent.FAULT,faultHandler);
	cProxy.process.addEventListener(ResultEvent.RESULT,authenticateHandler);
	cProxy.process({event:&quot;general.doRemoteLogin&quot;});
}
/* UTILITY METHOD TO GET A CBPROXY OBJECT, You can separate all this to a delegate class */
public function getColdBoxProxy():RemoteObject{
    var cProxy:RemoteObject = new RemoteObject(&quot;ColdFusion&quot;);
    cProxy.source = _model.cbProxyPath;
    cProxy.showBusyCursor = true;
    return cProxy;
}
&lt;/code&gt;
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<category>ColdFusion</category>
				
				<category>Flex/Flash/AS3</category>
				
				<pubDate>Tue, 20 Oct 2009 07:10:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/10/20/Using-do-as-the-event-name-in-Coldbox-dont</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Consume object or object property</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/6/20/Consume-object-or-object-property</link>
				<description>
				
				Here it is in a nutshell. I have a controller cfc in my framework that directs execution instructions to the business model cfc&apos;s. But I&apos;m wandering if I should pass whole objects, like a user object, and get values as needed from it&apos;s methods within the business model? Or should I just pass the object&apos;s properties to the business model classes as needed?

Another way to put it is this(model/securityService.cfc):
&lt;code&gt;
instance.securityGateway.login(User.getUsername(),User.getUserpassword());

or

instance.securityGateway.login(User);
&lt;/code&gt;

The business model gateway in this example would be something like(model/data/gateway/securityGateway.cfc):
&lt;code&gt;
&lt;cffunction name=&quot;login&quot;..&gt;
&lt;cfargument name=&quot;username&quot;../&gt;
&lt;cfargument name=&quot;password&quot;../&gt;
...
&lt;/cffunction&gt;

or

&lt;cffunction name=&quot;login&quot;..&gt;
&lt;cfargument name=&quot;User&quot; type=&quot;model.data.gateway.User&quot;../&gt;
..
&lt;/cffunction&gt;
&lt;/code&gt;

Maybe because I&apos;m not a seasoned OO veteran but I&apos;m looking at this and trying to figure out the best course and can&apos;t decide which one to take. From the service cfc do I pass in the user object or it&apos;s properties (username &amp; password)?

For now I&apos;m passing the object&apos;s properties if the gateway method only requires data and doesn&apos;t need to access any of the objects other methods like setters. If the gateway method here needed to use the object&apos;s methods instead of just it&apos;s properties, then I&apos;d pass the entire object. So what do you think is best practice?
				
				</description>
				
				<category>Bits and Bytes</category>
				
				<category>Coldbox 2.6</category>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<category>OOP/Patterns</category>
				
				<pubDate>Sat, 20 Jun 2009 07:03:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/6/20/Consume-object-or-object-property</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFC Method Testing in Coldbox</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/5/20/CFC-Method-Testing-in-Coldbox</link>
				<description>
				
				I got tired of trying to get cfUnit working and all I wanted to do was test component methods. I wanted to be able to simply point to it, test it, and enter arguments if required. And I wanted this set up somewhere easy I could use quickly, repeatedly, effortlessly, and painlessly (word?).

In almost all my applications I have a &apos;webmaster&apos; directory where I run test. Lately I&apos;ve found myself getting fancy with setting up a web development control panel of sorts. Whereas web sites generally have administration control for admin users, I&apos;ve been building in webmaster control for developers. Mostly things like server and framework info, links to documentation, framework and site functionality examples, and etc.

Now I&apos;m adding a little CFC Test form where I enter my cfc path, the method name, and arguments. It will pass the event argument so you can also test cfc handlers.

Warning, I just created this a few hours ago. It&apos;s tested to work but I haven&apos;t cleaned it up or put in validation and error handling yet.

views/webmaster/index.cfm (webmaster control panel)
&lt;code&gt;&lt;cfform name=&quot;cfctestform&quot; action=&quot;#cgi.SCRIPT_NAME#&quot; method=&quot;post&quot; format=&quot;html&quot;&gt;
	&lt;cfinput name=&quot;do&quot; type=&quot;hidden&quot; value=&quot;webmaster.panelcontrol.testmethod&quot; /&gt;
	&lt;cfinput name=&quot;sbIsEnabled&quot; type=&quot;hidden&quot; value=&quot;0&quot; /&gt;
	Enter Component Path:&lt;br /&gt;&lt;cfinput name=&quot;cfcpath&quot; type=&quot;text&quot; /&gt;
	&lt;br /&gt;
	Enter Method to Test:&lt;br /&gt;&lt;cfinput name=&quot;cfcmethod&quot; type=&quot;text&quot; /&gt;
	&lt;br /&gt;
	Arguments:(comma seperated list)&lt;br /&gt;&lt;cfinput name=&quot;methodargs&quot; type=&quot;text&quot; width=&quot;80&quot; /&gt;
	&lt;br /&gt;
	&lt;cfinput type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Run Test&quot; /&gt;
&lt;/cfform&gt;&lt;/code&gt;

events/webmaster/panelcontrol.cfc (Coldbox handler)
&lt;code&gt;&lt;cffunction name=&quot;testmethod&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;true&quot;&gt;
	&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;&gt;
	&lt;cfset var rc 		= arguments.event.getCollection()&gt;
	&lt;cfset var ret 		= &quot;&quot;&gt;
	&lt;cfset var cfcObj 	= createObject(&quot;component&quot;,rc.cfcpath)&gt;
	&lt;cfif listLen(rc.methodargs)&gt;
		&lt;cfloop from=&quot;1&quot; to=&quot;#listLen(rc.methodargs)#&quot; index=&quot;i&quot; step=&quot;2&quot;&gt;
			&lt;cfset evaluate(&quot;arguments[&apos;#listGetAt(rc.methodargs,i)#&apos;] = &apos;#listGetAt(rc.methodargs,i+1)#&apos;&quot;)&gt;
		&lt;/cfloop&gt;
	&lt;/cfif&gt;
	&lt;cfinvoke component=&quot;#rc.cfcpath#&quot; method=&quot;#rc.cfcmethod#&quot; argumentcollection=&quot;#arguments#&quot; returnvariable=&quot;ret&quot;&gt;
	&lt;cfscript&gt;
		//Display
		event.setValue(&quot;cfctestresults&quot;,ret);
		event.setValue(&quot;author&quot;,&quot;Clint Willard&quot;);
		event.setView(&quot;webmaster/dspCfcTestResult&quot;);
	&lt;/cfscript&gt;
&lt;/cffunction&gt;&lt;/code&gt;
Basically it loops through the method arguments list you entered in the form setting them as part of the arguments struct. That arguments struct is then passed to the invoked component and method, along with the event object. Then the view is set to output with the test results, whatever the method is set to return.

views/webmaster/dspcfcTestResult.cfm
&lt;code&gt;&lt;cfscript&gt;
	cfcresult = event.getValue(&quot;cfctestresults&quot;,&quot;NA&quot;);
&lt;/cfscript&gt;
&lt;cfoutput&gt;
	#dump(cfcresult)#
&lt;/cfoutput&gt;&lt;/code&gt;
KISS output.

Let me know if this might be a good idea to expand on or should I just LOL learn cfUnit? And the webmaster information and control panel stuff?
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<category>Resources</category>
				
				<pubDate>Wed, 20 May 2009 18:31:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/5/20/CFC-Method-Testing-in-Coldbox</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldbox model mappings script</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/5/17/Coldbox-model-mappings-script</link>
				<description>
				
				Tired of keeping your modelMappings.cfm file straight everytime you add or delete a model? What you need is a script that&apos;ll do it all automatically. This code isn&apos;t mine and I can&apos;t remember where I found it but it&apos;s very useful. Mind the OS slashes &apos;/&apos; and &apos;\&apos;, change as needed for your system, Windows or *nix, which can probably be parameterized too.

&lt;code&gt;&lt;cfscript&gt;  
/**  
* Deletes the n leftmost elements from the specified list.  
* Modified by RCamden  
*  
* @param list      The list to modify.  
* @param numElements      The number of elements to delete from the left hand side.  
* @param delimiter      The delimiter to use. Defaults to a comma.  
* @return Returns a string.  
* @author Shaun Ambrose (shaun.ambrose@arcorsys.com)  
* @version 1, April 24, 2002  
**/  
function ListDeleteLeft(list, numElements) {   
    var i=0;   
    var delimiter=&quot;,&quot;;   
       
    if (Arraylen(arguments) gt 2) {   
        delimiter=arguments[3];   
    }   
           
    if (numElements gt ListLen(list, delimiter)) return &quot;&quot;;   
       
    for (i=1; i lte numElements; i=i+1) {   
        list=listDeleteAt(list, 1, delimiter);   
    }   
    return list;   
}   
&lt;/cfscript&gt;  
&lt;!--- Add model mappings dynamically for all cfcs found in the /model directory ---&gt;  
&lt;cfdirectory action=&quot;list&quot; directory=&quot;#expandPath(&apos;/model&apos;)#&quot; name=&quot;files&quot; recurse=&quot;true&quot; /&gt;  
&lt;cfloop query=&quot;files&quot;&gt;  
    &lt;cfif right(files.name,4) is &quot;.cfc&quot;&gt;  
        &lt;!--- rip extension off component ---&gt;  
        &lt;cfset filename = left(files.name,len(files.name)-4)&gt;  
        &lt;cfset thisPath = listAppend(listDeleteLeft(files.directory,listFindNoCase(files.directory,&quot;model&quot;,&quot;\&quot;),&quot;\&quot;),filename,&quot;\&quot;) /&gt;  
        &lt;cfset addModelMapping(path=listChangeDelims(thisPath,&quot;.&quot;,&quot;\&quot;)) /&gt;  
    &lt;/cfif&gt;  
&lt;/cfloop&gt;&lt;/code&gt;
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Sun, 17 May 2009 21:10:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/5/17/Coldbox-model-mappings-script</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldbox Bean Factory</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/5/14/Coldbox-Bean-Factory</link>
				<description>
				
				Coldbox has a really cool bean factory that can speed up your development time. Through it&apos;s methods you can manage your bean objects with one-liners. Like, instead of having your handler get a bean form the gateway then filling or updating that bean with it&apos;s getters, you can simply tell the bean factory to do it for you.
&lt;code&gt;UserBean = getPlugin(&apos;beanFactory&apos;).getModel(&apos;data.bean.User&apos;);
getPlugin(&apos;beanFactory&apos;).populateBean(UserBean);&lt;/code&gt;
The example you see above gets a bean and populates or updates its properties via its setters automatically. Your next question is &quot;With what?&quot;

Let&apos;s imagine a form that a user fills out to update his address. Nevermind the code I&apos;m typing from my head, it&apos;s short to be to the point.
&lt;code&gt;&lt;form method=&quot;POST&quot; action=&quot;#cgi.SCRIPT_NAME#&quot;&gt;
&lt;cfinput type=&quot;hidden&quot; name=&quot;do&quot; value=&quot;general.editAddress&quot;/&gt;
&lt;cfinput type=&quot;text&quot; name=&quot;address&quot;/&gt;
&lt;cfinput type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;/&gt;
&lt;/form&gt;&lt;/code&gt;
Notice the name property for the text input where the address goes, &apos;address&apos;, case isn&apos;t important. It gets handled by the general handler in the events directory as an editAddress event, which runs the editAddress method of the general handler object.

And in the general handler is the editAddress event.
&lt;code&gt;&lt;cffunction name=&quot;editAddress&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;false&quot;&gt;
&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;/&gt;
&lt;cfset rc = event.getCollection()&gt;
&lt;cfscript&gt;
getPlugin(&apos;beanFactory&apos;).populateBean(variables.UserBean);
getPlugin(&apos;beanFactory&apos;).getModel(&apos;data.gateway.usersGateway&apos;).saveBean(variables.UserBean);
&lt;/script&gt;
&lt;/cffunction&gt;&lt;/code&gt;
With just this much code, after the form was submitted, my handler, with the bean factory, has updated the bean property &apos;address&apos; and used the gateway to update it in the database.

The populateBean method takes the request context, which contains the submitted form items such as &apos;address=1732 Main St.&apos; and finds the setter method matching the form names, or &apos;address&apos; in this case. Then it runs the setAddress() method of the bean, updating it.

You don&apos;t have to call out the bean&apos;s actual setter method in your code which is fantastic when your form has many more fields. You can also set a value in the request context that matches a bean&apos;s property name and then just use populateBean() to update it. The following code will include an update to the name properties of the user bean. If the user bean object has a setFirstName() and setLastName() method, then it&apos;s first and last name properties will also be updated.
&lt;code&gt;&lt;cffunction name=&quot;editAddress&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;false&quot;&gt;
&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;/&gt;
&lt;cfset rc = event.getCollection()&gt;
&lt;cfscript&gt;
rc.firstName = &quot;Clint&quot;;
rc.lastName = &quot;Eastwood&quot;;
getPlugin(&apos;beanFactory&apos;).populateBean(variables.UserBean);
getPlugin(&apos;beanFactory&apos;).getModel(&apos;data.gateway.usersGateway&apos;).saveBean(variables.UserBean);
&lt;/script&gt;
&lt;/cffunction&gt;&lt;/code&gt;
After the code above runs, UserBean.getFirstName() will return &apos;Clint&apos; now. As long as the property is spelled the same, &apos;firstname&apos;. You want to keep your object property names the same as in your database.

Maybe some time I&apos;ll go over the bean factory&apos;s model mapping and autowire methods but for now I&apos;m not using them and haven&apos;t yet found a reason to.
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Thu, 14 May 2009 14:50:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/5/14/Coldbox-Bean-Factory</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>ColdBox Model Dependencies</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/5/13/ColdBox-Model-Dependencies</link>
				<description>
				
				I found another way in ColdBox to inject dependencies within my model and data layer. I&apos;m not sure if it&apos;s newer or older than my current IOC only injection
&lt;code&gt;
&lt;cfcomponent name=&quot;general&quot; extends=&quot;coldbox.system.eventhandler&quot; output=&quot;false&quot; autowire=&quot;true&quot;&gt;
...
&lt;!------------------------------------------ DEPENDENCIES --------------------------------------&gt;
&lt;!--- Get User Service ---&gt;
&lt;cffunction name=&quot;getUsersService&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;any&quot; hint=&quot;Get usersService&quot;&gt;
&lt;cfreturn instance.usersService/&gt;
&lt;/cffunction&gt;	
&lt;cffunction name=&quot;setUsersService&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot; hint=&quot;Set usersService&quot;&gt;
&lt;cfargument name=&quot;usersService&quot; type=&quot;any&quot; required=&quot;true&quot;/&gt;
&lt;cfset instance.usersService = arguments.usersService/&gt;
&lt;/cffunction&gt;
&lt;!--- Get User Bean ---&gt;
&lt;cffunction name=&quot;getUsersBean&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;any&quot; hint=&quot;Get usersBean&quot;&gt;
&lt;cfreturn instance.usersBean/&gt;
&lt;/cffunction&gt;	
&lt;cffunction name=&quot;setUsersBean&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot; hint=&quot;Set usersBean&quot;&gt;
&lt;cfargument name=&quot;usersBean&quot; type=&quot;any&quot; required=&quot;true&quot;/&gt;
&lt;cfset instance.usersBean = arguments.usersBean/&gt;
&lt;/cffunction&gt;
...
&lt;/cfcomponent&gt;
&lt;/code&gt;
but it sure seems easier, cleaner, and coder intuitive. I&apos;m still using ColdSpring IOC for my data layer but now I&apos;m using ColdBox&apos;s own model injection. It (beanFactory) uses a modelMappings.cfm file in the config directory to list the metadata that&apos;s like model mappings.
&lt;code&gt;
cfscript&gt;
/* Add all the model mappings you want */
/* addModelMapping(alias=&quot;&quot;,path=&quot;&quot;) */
addModelMapping(path=&apos;UsersService&apos;);
addModelMapping(path=&apos;data.bean.Users&apos;);
&lt;/script&gt;
&lt;/code&gt;
Its intuitive enough to map the model name from the path or you can use an alias instead. Whether or not a huge application with a few thousand classes would bloat this file and slow things down would be an interesting question. But for now what makes this way better to me would be the more intuitive feeling of the metadata style dependency listings using the cfproperty tag in all my models 
&lt;code&gt;
&lt;cfcomponent name=&quot;testarea&quot; extends=&quot;coldbox.system.eventhandler&quot; output=&quot;false&quot; autowire=&quot;true&quot;&gt;
&lt;!----------------------------------- DEPENDENCIES --------------------------------------&gt;
&lt;cfproperty name=&quot;UsersService&quot; type=&quot;model&quot; scope=&quot;instance&quot; /&gt;
...
&lt;cffunction name=&quot;index&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;true&quot;&gt;
&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;&gt;
&lt;cfscript&gt;
//Logic
userName = instance.usersService.getUserName();
//Display
Event.setValue(&apos;userName&apos;,userName);
Event.setView(&quot;test&quot;);
&lt;/cfscript&gt;
&lt;/cffunction&gt;
...
&lt;/cfcomponent&gt;
&lt;/code&gt;
and frankly the modelMappings meta listing style actually helps with mental organization.

I&apos;m not sure if this way is supposed to be better, worse, or just different but I love it.
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Wed, 13 May 2009 17:31:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/5/13/ColdBox-Model-Dependencies</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldbox Development Environment</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2009/5/12/Coldbox-Development-Environment</link>
				<description>
				
				One of the newest enhancements to Coldbox (2.6) is an environments.xml.cfm file in the config directory you can use to override application settings depending on what box your on. Even if you work on a DEV server, test on a QA server, and publish to the PRODUCTION server, you can set settings like caching and auto reloading for each box and forget it.

For example you can set &lt;Setting name=&quot;DebugMode&quot; value=&quot;false&quot; /&gt; in the coldbox.xml.cfm for production but override that in environments.xml.cfm with &amp;lt;Setting name=&quot;DebugMode&quot; value=&quot;true&quot; /&amp;gt;. So if your dev environment url parameter in the environment.xml.cfm is &apos;localhost&apos;, then when the cgi.http_host equals &apos;localhost&apos; instead of &apos;mysite.com&apos; the debugmode value will be &apos;true&apos;. And without changing a thing, it will be &apos;false&apos; in production. There is no need to set a production environment in environments.xml.cfm as CB will use coldbox.xml.cfm settings only if cgi.http_host isn&apos;t found.
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Tue, 12 May 2009 08:15:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2009/5/12/Coldbox-Development-Environment</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldbox Framework and Ajax: cfajaxproxy</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/10/16/Coldbox-Framework-and-Ajax-cfajaxproxy</link>
				<description>
				
				After working in Coldbox for a while I know your first instinct is to make a cfajaxproxy call to a cfc event just like all the other Coldbox events. However, using cfajaxproxy is just a little different. Here is an example to show you one simple way of doing it, not the only way but one of them.

First let me note that I am using Coldspring version of IOC. It should work the same though with any form of IOC. Mostly we need the IOC to provide the bean to the services your Ajax call requires from within the Coldbox proxy.

After having provided a service in Coldspring like so:
&lt;code&gt;
&lt;bean id=&quot;usersService&quot; class=&quot;model.usersService&quot;&gt;
  &lt;constructor-arg name=&quot;privatemessagesGateway&quot;&gt;
    &lt;ref bean=&quot;privatemessagesGateway&quot;/&gt;
  &lt;/constructor-arg&gt;
  &lt;constructor-arg name=&quot;ColdBoxController&quot;&gt;
    &lt;ref bean=&quot;ColdBoxController&quot;/&gt;
  &lt;/constructor-arg&gt;
&lt;/bean&gt;
&lt;/code&gt;

we can use this &quot;usersService&quot; bean in the coldboxproxy.cfc like this:
&lt;code&gt;
	&lt;cffunction name=&quot;ajxSetPMRead&quot; access=&quot;remote&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;
		&lt;cfargument name=&quot;messageid&quot; type=&quot;String&quot; required=&quot;true&quot;/&gt;
		&lt;cfset var pm = getBean(&apos;usersService&apos;).getPrivateMessageByID(int(arguments.messageid))&gt;
		&lt;cfset pm.setRead(1)&gt;
		&lt;cfset getBean(&apos;usersService&apos;).savePrivateMessage(pm)&gt;
	&lt;/cffunction&gt;
&lt;/code&gt;

The code above is what the Ajax, cfcajaxproxy, will call as a method for Coldbox to perform. It fetches a private message object bean, sets or updates some properties, then uses the gateway to save the object bean. I don&apos;t have a return or output but you can do that also here if desired. And here is the actual view and Ajax calling code:
&lt;code&gt;
&lt;cfajaxproxy cfc=&quot;coldboxproxy&quot; jsclassname=&quot;cbProxy&quot;&gt;

&lt;a href=&quot;##&quot; onClick=&quot;showMessageDetails(&apos;#privateMessagesQuery.privatemessageid#&apos;,&apos;#privateMessagesQuery.read#&apos;,&apos;#privateMessagesQuery.subject#&apos;,&apos;#privateMessagesQuery.fromUserName#&apos;,&apos;#privateMessagesQuery.message#&apos;)&quot;&gt;#privateMessagesQuery.subject#&lt;/a&gt;

&lt;$cript&gt;
function showMessageDetails(messageid,read,subject,from,message){
	var e = new cbProxy();
	if(read == 0){
		e.setCallbackHandler(setPrivateMessageRead);
	    e.setErrorHandler(ajaxErrorHandler);
	    e.ajxSetPMRead(messageid);
	}
	document.getElementById(&apos;pmReply&apos;).style.display = &quot;none&quot;;
	document.getElementById(&apos;pmDetails&apos;).style.display = &quot;inline&quot;;
	document.getElementById(&apos;pmDetails_Subject&apos;).innerHTML=subject;
	document.getElementById(&apos;pmDetails_From&apos;).innerHTML=from;
	document.getElementById(&apos;pmDetails_Message&apos;).innerHTML=message;
}
var setPrivateMessageRead = function(res){
	alert(&apos;set to read&apos;);
}
var ajaxErrorHandler = function(statusCode, statusMsg){
	alert(&apos;Status: &apos; + statusCode + &apos;, &apos; + statusMsg);
}
&lt;/script&gt;
&lt;/code&gt;
The cfc attribute is dot notation to the location of your coldboxproxy.cfc, mine here is at the root. Basically I&apos;m showing the private message details in a div but needing to set the read flag in the database to 1 to indicate it has been read. And using Ajax I can set this in the database for each message read without a page refresh. The alerts in the javascript are for demonstration and testing purposes.

The code I provided is a cut down version of actual code and does not include the view event, form code, queries, or other behind the scenes code. I hope this helps to give you a step ahead on how to use Ajax with the Coldbox framework.
				
				</description>
				
				<category>JavaScript/Ajax</category>
				
				<category>Frameworks</category>
				
				<category>ColdSpring</category>
				
				<category>ColdFusion</category>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Thu, 16 Oct 2008 08:19:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/10/16/Coldbox-Framework-and-Ajax-cfajaxproxy</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Create Coldbox plugin example</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/6/6/Create-Coldbox-plugin-example</link>
				<description>
				
				Coldbox plugins are a really useful aspect of the framework when you want to create reusable interfunctions. Interfunction is a term for a function within an application that can be used in any application within any one specific framework.

Coldbox plugin interfunctions are, to me, like UDFs, almost. Except that they are OO capable components. But enough with talk, read more about plugins &lt;a href=&quot;http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbMyFirstPlugin&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.

And here&apos;s an example of a custom plugin I created called &quot;MyUtilities&quot; that has a function utilizing CF8&apos;s new image resizing abilities. It&apos;s not expanded yet as this is just what I needed for the moment on a project.

This goes into a cfc (MyUtilities.cfc) file in your plugins directory, I called this plugin &quot;MyUtilities&quot; for now:
&lt;code&gt;&lt;cfcomponent name=&quot;MyUtilities&quot;
       		 hint=&quot;This is a Utilities CFC&quot;
       		 extends=&quot;coldbox.system.plugin&quot;
       		 output=&quot;false&quot;
       		 cache=&quot;true&quot;
       		 cachetimeout=&quot;5&quot;&gt;
			
	&lt;cffunction name=&quot;resizeImage&quot; access=&quot;public&quot; returntype=&quot;Any&quot;&gt;
		&lt;cfargument name=&quot;fileLocation&quot; type=&quot;String&quot; required=&quot;true&quot;/&gt;
		&lt;cfargument name=&quot;destination&quot; type=&quot;String&quot; required=&quot;false&quot; default=&quot;#arguments.fileLocation#&quot;&gt;
		&lt;cfargument name=&quot;xWidth&quot; type=&quot;String&quot; required=&quot;false&quot; default=&quot;100&quot;/&gt;
		&lt;cfargument name=&quot;yHeight&quot; type=&quot;String&quot; required=&quot;false&quot; default=&quot;100&quot;/&gt;
		&lt;cfscript&gt;
			if(IsImageFile(&quot;#arguments.fileLocation#&quot;)){
				myImage		= ImageNew(arguments.fileLocation);
				ImageSetAntialiasing(myImage,&quot;on&quot;);
				ImageScaleToFit(myImage,arguments.xWidth,arguments.yHeight,&quot;highestQuality&quot;);
				ImageWrite(myImage,arguments.destination,1);
				return ImageInfo(myImage);
			}else{
				return false;
			}
		&lt;/cfscript&gt;
	&lt;/cffunction&gt;
	
&lt;/cfcomponent&gt;&lt;/code&gt;

And this is how you&apos;d use it in your code:
&lt;code&gt;imageThumb = getPlugin(&quot;MyUtilities&quot;,true).resizeImage(fileLocation,thumbLocation,width,height);&lt;/code&gt;

You can see from the resizeImage function that I hard coded resize quality and antialiasing, as that is true anywhere in my project for all image sizing. But you can take this and customize it further for your needs. I just mostly wanted to share with you an example of using a custom Coldbox plugin.
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<category>Frameworks</category>
				
				<pubDate>Fri, 06 Jun 2008 06:13:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/6/6/Create-Coldbox-plugin-example</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldbox beanfactory populatebean method</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/6/4/Coldbox-beanfactory-populatebean-method</link>
				<description>
				
				I have to say I love this automatic bean population thing going around. Model-Glue does it also but since I mostly use Coldbox, that&apos;s what I&apos;m showing here.

WTF, you may ask? Well, you know how when you submit a form to edit a user account for example, and then you have to pass all those form elements to your user bean object&apos;s getters and setters one by one. userObj.setUsername(form.username), userObj.setUserpassword(form.password) and so on.. well you can forget about ever doing this again.

HOW!?!? By using the Coldbox beanfactory populatebean method. You can play with form elements first if you need to, then simply call the populate method passing in the current userbean, and then Coldbox will match form elements to the bean&apos;s getter and do the heaving lifting for you returning an updated bean ready for saving.

2 simple lines, get bean and populate bean. Then do whatever else you prefer from there to save it wherever etc..

&lt;code&gt;&lt;cffunction name=&quot;doEditAccount&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;false&quot;&gt;
		&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;&gt;
		&lt;!--- Logic ---&gt;
		&lt;cfscript&gt;
			userBean = getPlugin(&quot;sessionstorage&quot;).getVar(&quot;User&quot;);
			getPlugin(&quot;beanFactory&quot;).populateBean(userBean);
			getUsersService().saveUser(userBean);
			getPlugin(&quot;sessionstorage&quot;).setVar(&quot;User&quot;,userBean);
		&lt;/cfscript&gt;
		&lt;!--- Display ---&gt;
		&lt;cfset setNextEvent(&quot;myaccount.general.dspAccountHome&quot;)&gt;
	&lt;/cffunction&gt;&lt;/code&gt;

The most important thing to remember is that your actual bean cfc object must use an init method with setters. And the form element names should be the same as the bean names.

A bean&apos;s init:
&lt;code&gt;&lt;cffunction name=&quot;init&quot; returntype=&quot;User&quot;&gt;
&lt;cfargument name=&quot;username&quot;&gt;
&lt;cfset setUsername(arguments.username)&gt;
&lt;/cffunction&gt;&lt;/code&gt;

So that:
&lt;code&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot;&gt;&lt;/code&gt;
Matches:
&lt;code&gt;&lt;cffunction name=&quot;setUsername&quot;&gt;
&lt;cfargument name=&quot;var&quot;&gt;
&lt;cfset variables.instance.username = arguments.var&gt;
&lt;/cffunction&gt;&lt;/code&gt;

Hope that helps. :)
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<category>ColdFusion</category>
				
				<category>Frameworks</category>
				
				<category>OOP/Patterns</category>
				
				<pubDate>Wed, 04 Jun 2008 19:20:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/6/4/Coldbox-beanfactory-populatebean-method</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Dynamic column layouts in Coldbox</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/6/1/Dynamic-column-layouts-in-Coldbox</link>
				<description>
				
				Possibly like me, you have a site that can be thought of as sections. An example would be an ecommerce site with product categories such as electronics, garden, books, movies, and others. The idea behind dynamic columns in Coldbox is that for each section I just mentioned, you may want to display content in the left column of your site specific for that section only and an element or two common to all of them.

There may very well be several ways to accomplish this small task and I&apos;m going to show you one of mine. So lets just jump right in. If you&apos;re like me, your just skimming though this any ways and so I&apos;ll just make a list type explaination.

&lt;li&gt;This example uses one layout file for multiple sections of the site where each section will have a different left column layout.&lt;/li&gt;
&lt;li&gt;Each section will have it&apos;s own left column display file.&lt;/li&gt;
&lt;li&gt;Each column file will render boxes within it ordered as needed.&lt;/li&gt;

So your views directory would look something like:&lt;br&gt;
-views&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;-boxes&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;menu.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tvSuppliers.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gardenTips.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;weather.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;information.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;-elements&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;header.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;footer.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;leftColumn_Electronics.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;leftColumn_Garden.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;-electronics&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;home.cfm&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;-gardens&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;home.cfm&lt;br&gt;

And here&apos;s how the layout template uses these elements:
&lt;code&gt;&lt;body&gt;
&lt;cfoutput&gt;
&lt;div id=&quot;pageContent&quot;&gt;
	&lt;div id=&quot;bannerContent&quot;&gt;
		#renderView(&apos;elements/header&apos;)#
	&lt;/div&gt;
	&lt;div id=&quot;bodyContent&quot;&gt;
		&lt;div id=&quot;leftContent&quot;&gt;
			&lt;cfswitch expression=&quot;#rc.section#&quot;&gt;
				&lt;cfcase value=&quot;electronics&quot;&gt;
					#renderView(&apos;elements/leftColumn_Electronics&apos;)#
				&lt;/cfcase&gt;
				&lt;cfcase value=&quot;garden&quot;&gt;
					#renderView(&apos;elements/leftColumn_Garden&apos;)#
				&lt;/cfcase&gt;
				&lt;cfdefaultcase&gt;
					#renderView(&apos;elements/leftColumn&apos;)#
				&lt;/cfdefaultcase&gt;
			&lt;/cfswitch&gt;
		&lt;/div&gt;
		&lt;div id=&quot;centerContent&quot;&gt;
			#renderView()#
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;footContent&quot;&gt;
	#renderView(&apos;elements/footer&apos;)#
&lt;/div&gt;
&lt;/cfoutput&gt;
&lt;/body&gt;&lt;/code&gt;

And in the elements, you place the boxes you want, order and whatever layout.
&lt;br&gt;
leftColumn_garden.cfm for example:
&lt;code&gt;&lt;cfoutput&gt;
	#renderView(&apos;/boxes/menu&apos;)#
	#renderView(&apos;/boxes/gardenTips&apos;)#
	#renderView(&apos;/boxes/information&apos;)#
&lt;/cfoutput&gt;&lt;/code&gt;

And of course the handler. I usually place the layout variables in here as such:
&lt;code&gt;&lt;!--- Display ---&gt;
&lt;cfset Event.setValue(&apos;pageTitle&apos;,&quot;MyWebsite Name - Gardens&quot;)&gt;
&lt;cfset Event.setValue(&apos;section&apos;,&quot;garden&quot;)&gt;
&lt;cfset Event.setView(&quot;gardens/home&quot;)&gt;&lt;/code&gt;

That&apos;s it and about as simple a plan as I could come with in my limited Coldbox knowledge. I&apos;m sure it can be automated somewhat a little more or better simplified. Frankly I couldn&apos;t find any info online myself to show such an example but your more than welcomed to one up on me. Hope this helps.
				
				</description>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Sun, 01 Jun 2008 10:37:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/6/1/Dynamic-column-layouts-in-Coldbox</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>ColdSpring ColdboxFactory: DSN and Mail settings</title>
				<link>http://www.cfcdeveloper.com/index.cfm/2008/5/26/ColdSpring-ColdboxFactory-DSN-and-Mail-settings</link>
				<description>
				
				My second day into figuring out Coldbox, here&apos;s a little something cool. Putting it simply, using ColdSpring, in the CS.xml you can define a &apos;coldboxFactory&apos; bean to use in creating other beans that define this factory&apos;s methods as beans also, then pass that bean into a class bean&apos;s property as a bean reference.

Actually, that doesn&apos;t sound simple as it is, so here&apos;s an example. Remember that I&apos;m a newbie, so be nice.

coldbox.xml.cfm
&lt;code&gt;
&lt;MailServerSettings&gt;
	&lt;MailServer&gt;mail.urserver.com&lt;/MailServer&gt;
	&lt;MailPort&gt;25&lt;/MailPort&gt;
	&lt;MailUsername&gt;username&lt;/MailUsername&gt;
	&lt;MailPassword&gt;password&lt;/MailPassword&gt;
&lt;/MailServerSettings&gt;

&lt;Datasources&gt;
	&lt;Datasource alias=&quot;DSNAlias&quot; name=&quot;dsnName&quot; dbtype=&quot;mysql&quot; username=&quot;name&quot; password=&quot;pass&quot; /&gt;
&lt;/Datasources&gt;
&lt;/code&gt;I&apos;ve set mail settings and data source settings here in the main Coldbox config. I&apos;ll be using Coldspring for IoC and so I&apos;ll need to be able to pass this around in my beans.

Coldspring.xml
&lt;code&gt;
&lt;beans&gt;
	&lt;bean id=&quot;coldboxFactory&quot; class=&quot;coldbox.system.extras.ColdboxFactory&quot; /&gt;
	&lt;bean id=&quot;ConfigBean&quot; factory-bean=&quot;ColdboxFactory&quot; factory-method=&quot;getConfigBean&quot; /&gt;
	
	&lt;bean id=&quot;dsnBean&quot; factory-bean=&quot;ColdboxFactory&quot; factory-method=&quot;getDatasource&quot;&gt;
	   &lt;constructor-arg name=&quot;alias&quot;&gt;
	       &lt;value&gt;DSNAlias&lt;/value&gt;
	   &lt;/constructor-arg&gt;
	&lt;/bean&gt;
			
	&lt;bean id=&quot;cfctest&quot; class=&quot;handlers.cfctest&quot;&gt;
		&lt;property name=&quot;dsnBean&quot;&gt;
			&lt;ref bean=&quot;dsnBean&quot; /&gt;
        &lt;/property&gt;
		&lt;property name=&quot;ConfigBean&quot;&gt;
			&lt;ref bean=&quot;ConfigBean&quot; /&gt;
        &lt;/property&gt;
	&lt;/bean&gt;
&lt;/beans&gt;
&lt;/code&gt;This coldboxFactory has several methods that interface with the coldbox config file, among other things I&apos;m sure. Check out the &lt;a href=&quot;http://www.coldboxframework.com/api/&quot; target=&quot;_blank&quot;&gt;API&lt;/a&gt; for more info. But basically I create the coldboxFactory bean, then create other beans of the factory&apos;s methods. Then notice how I pass those beans into the handler beans by reference. These &apos;properties&apos;, as it turns out, are setters in the cfc, such as setDsnBean and setConfigBean. Then I just put them in variables for my other methods.

cfctest.cfc
&lt;code&gt;
&lt;cfcomponent output=&quot;false&quot;&gt;
	&lt;cffunction name=&quot;setDSNBean&quot; access=&quot;public&quot; returntype=&quot;void&quot;&gt;
		&lt;cfargument name=&quot;DSNBean&quot; type=&quot;Any&quot; required=&quot;true&quot;/&gt;
		&lt;cfset variables.dsn = arguments.DSNBean.getName()&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction name=&quot;setConfigBean&quot; access=&quot;public&quot; returntype=&quot;void&quot;&gt;
		&lt;cfargument name=&quot;configBean&quot; type=&quot;Any&quot; required=&quot;true&quot;/&gt;
		&lt;cfset variables.mailName = arguments.configBean.getKey(&quot;mailUsername&quot;)&gt;
	&lt;/cffunction&gt;
	
	&lt;cffunction name=&quot;capitalize&quot; access=&quot;public&quot; returntype=&quot;string&quot;&gt;
		&lt;cfargument name=&quot;string&quot; type=&quot;string&quot; required=&quot;true&quot;/&gt;
		&lt;cfreturn Ucase(variables.mailName &amp; &quot; - &quot; &amp; arguments.string)/&gt;
	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;
&lt;/code&gt;Don&apos;t dis my cfc, I&apos;m just playing around and testing stuff. Notice the setters that I mentioned before. If you do a dump/abort on these at run time you&apos;ll see what use they are.

general.cfc
&lt;code&gt;
&lt;cffunction name=&quot;index&quot; access=&quot;public&quot; returntype=&quot;void&quot; output=&quot;false&quot;&gt;
	&lt;cfargument name=&quot;Event&quot; type=&quot;coldbox.system.beans.requestContext&quot;&gt;
	
	&lt;!--- Logic ---&gt;
	&lt;cfset string = &quot;Welcome!&quot;&gt;
	&lt;cfset string = variables.ioc.getBean(&quot;cfctest&quot;).capitalize(string)&gt;
	&lt;cfset Event.setValue(&quot;welcomeMessage&quot;,string)&gt;	
	
	&lt;!--- Display ---&gt;
	&lt;cfset Event.setView(&quot;home&quot;)&gt;
&lt;/cffunction&gt;
&lt;/code&gt;And finally here&apos;s the handler that uses the IoC plugin I set in variables in the handler&apos;s init function that gets the bean set in Coldspring and runs the method that utilizes all the stuff we just went through. Check out &lt;a href=&quot;http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbColdspringGuide&quot; target=&quot;_blank&quot;&gt;Coldbox&apos;s Coldspring documentation&lt;/a&gt; for more information.

There are other factories to use I&apos;m guessing and other factory methods within those. You can use all the methods in the coldbox.system.controller as beans also. But like I said, I&apos;m just discovering this stuff right now. Frankly I need to think over wether or not passing bean reference properties to all my CS beans is the most effective way of using global configs any ways. Seems rather repetative as apposed to putting such things in a request scope through onRequestStart or something.
				
				</description>
				
				<category>Frameworks</category>
				
				<category>ColdSpring</category>
				
				<category>ColdFusion</category>
				
				<category>Coldbox 2.6</category>
				
				<pubDate>Mon, 26 May 2008 06:06:00 -0700</pubDate>
				<guid>http://www.cfcdeveloper.com/index.cfm/2008/5/26/ColdSpring-ColdboxFactory-DSN-and-Mail-settings</guid>
				
			</item>
			
		 	
			</channel></rss>
	

