<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fusioncube &#187; coldspring</title>
	<atom:link href="http://www.fusioncube.net/index.php/category/development/frameworks/coldspring/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fusioncube.net</link>
	<description>The online journey of a technophile, by Steve Brownlee</description>
	<lastBuildDate>Wed, 01 Feb 2012 04:17:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>New AjaxCFCProxy class for Sencha ExtJS</title>
		<link>http://www.fusioncube.net/index.php/new-ajaxcfcproxy-class-for-sencha-extjs</link>
		<comments>http://www.fusioncube.net/index.php/new-ajaxcfcproxy-class-for-sencha-extjs#comments</comments>
		<pubDate>Fri, 15 Apr 2011 15:47:56 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldspring]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ajaxcfc]]></category>
		<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[ext.data.store]]></category>
		<category><![CDATA[ext.form.combobox]]></category>
		<category><![CDATA[httpproxy]]></category>
		<category><![CDATA[memoryproxy]]></category>
		<category><![CDATA[Sencha]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=1176</guid>
		<description><![CDATA[In my continued integration of ExtJS and ColdFusion, I've created a new DataProxy sub-class to utilize a predefined AJAX call rather than a URL to a separate page.]]></description>
			<content:encoded><![CDATA[<p>Related Article(s): <a href="http://www.fusioncube.net/index.php/porting-my-coldspring-enabled-ajaxcfc-code-to-extjs">AjaxCFC ported to ExtJS</a></p>
<p>My integration of ExtJS, ajaxCFC and ColdFusion continues.</p>
<p>Note: This is for version 3.3.1. I&#8217;ve also been happily playing around with version 4, but until it&#8217;s officially released, I must continue building with 3.3.1.</p>
<p>Anyway, here&#8217;s what I was trying to solve. When I want to allow users to serach for items from a <a href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.ComboBox" target="_blank">ComboBox</a>, I configure a store, and inside the store, I configure an <a href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.HttpProxy" target="_blank">Ext.data.HttpProxy</a> to hit a separate ColdFusion page that performs a query and returns the results.</p>
<h3>Standard HttpProxy Method</h3>
<pre class="brush: jscript; title: ; notranslate">
var WidgetStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        url: 'liveQueries/widgets.cfm'
    }),
    reader: new Ext.data.JsonReader({
        root: 'data',
        totalProperty:'totalRecords'
    }, Widget)
});
</pre>
<h3>ColdFusion &#8216;Live&#8217; Query</h3>
<pre class="brush: coldfusion; title: ; notranslate">
&lt;cfsetting enablecfoutputonly=&quot;true&quot;&gt;

&lt;cfparam name=&quot;query&quot; default=&quot;&quot;&gt;

&lt;cfquery name=&quot;chargeCodes&quot; datasource=&quot;#getDatasource().getName()#&quot;&gt;
SELECT UNIQUE widget_seq_no, identifier, descr
FROM 	widgets
WHERE 	(REGEXP_LIKE(identifier,&lt;cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;^#query#&quot;&gt;,'i')
   OR REGEXP_LIKE(descr,&lt;cfqueryparam cfsqltype=&quot;cf_sql_varchar&quot; value=&quot;^#query#&quot;&gt;,'i'))
   AND widget_type_cd='SNAPPYDS'
ORDER BY identifier asc
&lt;/cfquery&gt;

&lt;cfscript&gt;
jsonBean = createobject(&quot;component&quot;,&quot;ajaxCFC.JSON&quot;);
jsonEncodedCriteria = jsonBean.encode(data=chargeCodes, queryFormat=&quot;array&quot;);
writeOutput(jsonEncodedCriteria);
&lt;/coldfusion&gt;

&lt;cfsetting enablecfoutputonly=&quot;false&quot;&gt;
</pre>
<p>I hate this, because I already am using my <a href="http://www.fusioncube.net/index.php/porting-my-coldspring-enabled-ajaxcfc-code-to-extjs" target="_blank">Ext.AjaxCFC</a> class to query my <a href="http://www.coldspringframework.org/" target="_blank">ColdSpring</a> beans asynchronously, so why do I have to set up these standalone ColdFusion pages to performs queries that should be executed in the component?</p>
<p>I decided to take matters into my own hands, and I have to give the ExtJS team props again, because it was easy to accomplish by extending the <a href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.MemoryProxy" target="_blank">Ext.data.MemoryProxy</a> class. As you can see, all I need to do is override the doRequest() method to execute Ext.AjaxCFC.request() with the data passed in during initialization.</p>
<h3>Ext.ux.data.AjaxCFCProxy.js</h3>
<pre class="brush: jscript; title: ; notranslate">
Ext.ns('Ext.ux.data');

Ext.ux.data.AjaxCFCProxy = Ext.extend(Ext.data.MemoryProxy, {
   constructor : function(data){
      Ext.ux.data.AjaxCFCProxy.superclass.constructor.call(this);
      this.data = data;
   },
   doRequest : function(action, rs, params, reader, callback, scope, arg){
      this.data.data.query = params.query;
      Ext.AjaxCFC.request({
         bean : this.data.bean,
         method : this.data.method,
         data : this.data.data,
         success: function(rs) {
            var result = reader.readRecords(rs);
            callback.call(scope, result, arg, true);
         },
         error: function(results) {
            Ext.MessageBox.alert('Load Failed', 'Unable to load requested data');
         }
      });
   }
});
</pre>
<h3>New and Improved Combobox for Searching</h3>
<pre class="brush: jscript; title: ; notranslate">
WidgetSearch = new Ext.form.ComboBox({
    minChars:           2,
    loadingText:        '',
    itemSelector:       'div.search-item',
    triggerClass:       'x-form-search-trigger',
    emptyText:          '',
    width:              300,
    listWidth:          0,
    store: new Ext.data.Store({
        // I've extended the base Ext.data.MemoryProxy()
        // class to use the AjaxCFC object for searching
        // instead of having to use a liveQuery. Much cleaner.
        proxy: new Ext.ux.data.AjaxCFCProxy({
            bean    : 'Widget',
            method  : 'search',
            data    : { source_table : 'WIDGET' }
        }),
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/new-ajaxcfcproxy-class-for-sencha-extjs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Porting my ColdSpring-enabled AjaxCFC code to ExtJS</title>
		<link>http://www.fusioncube.net/index.php/porting-my-coldspring-enabled-ajaxcfc-code-to-extjs</link>
		<comments>http://www.fusioncube.net/index.php/porting-my-coldspring-enabled-ajaxcfc-code-to-extjs#comments</comments>
		<pubDate>Tue, 07 Dec 2010 17:28:33 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[ajaxCFC]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[ajaxcfc]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[Sencha]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/index.php/porting-my-coldspring-enabled-ajaxcfc-code-to-extjs</guid>
		<description><![CDATA[I&#8217;ve been using the AjaxCFC library for years. It&#8217;s my preferred way of integrating Javascript and ColdFusion via AJAX. I&#8217;ve even modified it from its original form so that my implementation was strictly for integration with jQuery, only returns JSON strings (ignoring WDDX and simple string), and can work with ColdSpring. Now that I&#8217;m a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using the <a href="http://ajaxcfc.riaforge.org/index.cfm" target="_blank">AjaxCFC</a> library for years. It&#8217;s my preferred way of integrating Javascript and ColdFusion via AJAX. I&#8217;ve even modified it from its original form so that my implementation was strictly for integration with <a href="http://jquery.com/" target="_blank">jQuery</a>, only returns JSON strings (ignoring WDDX and simple string), and can <a href="http://www.fusioncube.net/index.php/invoking-coldspring-bean-with-ajaxcfc" target="_blank">work with ColdSpring</a>.</p>
<p>Now that I&#8217;m a heavy user of the <a href="http://www.sencha.com/products/js/" target="_blank">Sencha ExtJS framework</a>, I thought it would be useful to port the jQuery.ajaxCFC.js file over to an Ext.AjaxCFC.js file that extended the native <a href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Connection" target="_blank">Ext.data.Connection</a> class and utilized the <a href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.Ajax" target="_blank">Ext.Ajax</a> object.</p>
<p>Took me about half the day, but I finally got a working Ext.AjaxCFC.request() method that uses the same syntax as the $.AjaxCFC() method. For those familiar with the inner workings and code of the jQuery AjaxCFC class, this will look very familiar.</p>
<p>So now I can make AJAX calls using native ExtJS classes, access ColdSpring beans in my application&#8217;s bean factory, or connect directly to any CFC</p>
<h3>Ext.AjaxCFC.js</h3>
<pre class="brush: jscript; title: ; notranslate">
Ext.AjaxCFCConnection = Ext.extend(Ext.data.Connection, {
   data        : null,
   queryFormat : 'array',
   factory     : (typeof(__ajaxConfig) == 'undefined') ? null : __ajaxConfig.beanFactory,
   timeout     : (typeof(__ajaxConfig) == 'undefined') ? 30000 : __ajaxConfig.defaultTimeout,
   url         : __ajaxConfig.url,
   bean        : null,

   request : function(arguments) {
      var params = (typeof(arguments.data) == 'undefined') ? {} : arguments.data;
      arguments.params = {};
      arguments.params['C0-ID']         = (Math.floor(Math.random() * 10001) + &quot;_&quot; + new Date().getTime()).toString(),
      arguments.params['method']        = 'init';
      arguments.params['component']     = arguments.component;
      arguments.params['bean']          = (typeof(arguments.bean) == 'undefined') ? this.bean : arguments.bean;
      arguments.params['factory']       = this.factory;
      arguments.params['C0-METHODNAME'] = arguments.method;
      arguments.params['queryFormat']   = (typeof(arguments.queryFormat) == 'undefined') ? this.queryFormat : arguments.queryFormat;
      arguments.params['C0-PARAM0']     = params;

      arguments.url = this.url + '?method=' + arguments.params['method'];
      arguments.method = 'POST';
      arguments.failure = arguments.error;
      arguments.timeout = this.timeout;

      var ____success = arguments.success;

      arguments.success = function(data) {
         data = data.responseText.replace(/^\s*|\s*$/g, '');

         if (data.substring(0,9) == '__json__:') {
            data = Ext.util.JSON.decode(data.slice(9));
         }
         ____success(data, this);
      };

      if ( params ) {
         if (typeof params != 'string') {
            arguments.params['C0-PARAM0'] = Ext.util.JSON.encode(params);
         }
      }

      Ext.Ajax.request(arguments);
   }
});

Ext.AjaxCFC = new Ext.AjaxCFCConnection();
</pre>
<h3>Usage</h3>
<pre class="brush: jscript; title: ; notranslate">
// Include Ext.AjaxCFC code
&lt;script type=&quot;text/javascript&quot; src=&quot;js/Ext.AjaxCFC.js&quot;&gt;&lt;/script&gt;

// Default configuration properties for the ajaxCFC library
__ajaxConfig = {
   'url':'/myApp/ajaxCFC/ajax.cfc',
   'defaultTimeout':30000,
   'beanFactory':'application.beanFactory'
};

// AjaxCFC call using Ext.data.Connection class
Ext.AjaxCFC.request({
   bean: 'AColdSpringBean',
   method: 'aMethod',
   data: {
      'id': 416198,
      'first_name': 'Steve',
      'last_name': 'Brownlee'
   },
   success: function(details, s){
      DataStore.loadData(details);
   },
   error: function(results){
      Ext.MessageBox.alert('Search Failed', 'An unexpected error occurred. Please try again.');
   }
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/porting-my-coldspring-enabled-ajaxcfc-code-to-extjs/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ColdFusion Object Creation &#8211; More</title>
		<link>http://www.fusioncube.net/index.php/coldfusion-object-creation-more</link>
		<comments>http://www.fusioncube.net/index.php/coldfusion-object-creation-more#comments</comments>
		<pubDate>Fri, 13 Feb 2009 04:51:52 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[design patterns]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=319</guid>
		<description><![CDATA[Following up on my original post about ColdFusion performance hits on creating objects &#8211; it was suggested that I return an array of typed structures instead of an array of components. I already had a nice AOP class for each of these scenarios, so all I had to do was add the __type__ column to [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on my <a href="http://www.fusioncube.net/index.php/coldfusion-object-creation-performance-hit">original post about ColdFusion performance hits on creating objects</a> &#8211; it was suggested that I return an array of typed structures instead of an array of components.</p>
<p>I already had a nice AOP class for each of these scenarios, so all I had to do was add the __type__ column to the array of structures, and I was good.  The test results below seem logical&#8230; except for the first set of testing 50 rows.  Converting the query results into an array of structs using a simple function call to another component was actually SLOWER than using AOP or converting to DTOs.</p>
<p>Besides that anomaly, the performance hit for using ColdSpring AOP proxies and using DTOs is clearly visible as you add more data.</p>
<p><img src="http://www.fusioncube.net/wp-content/uploads/2009/02/50rows.png" alt="50rows" title="50rows" width="406" height="223" class="alignnone size-full wp-image-320" /><br />
<br/><br/><br />
<img src="http://www.fusioncube.net/wp-content/uploads/2009/02/250rows.png" alt="250rows" title="250rows" width="412" height="221" class="alignnone size-full wp-image-321" /><br />
<br/><br/><br />
<img src="http://www.fusioncube.net/wp-content/uploads/2009/02/500rows.png" alt="500rows" title="500rows" width="420" height="225" class="alignnone size-full wp-image-322" /><br />
<br/><br/><br />
<img src="http://www.fusioncube.net/wp-content/uploads/2009/02/1000rows.png" alt="1000rows" title="1000rows" width="416" height="229" class="alignnone size-full wp-image-323" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldfusion-object-creation-more/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ColdFusion to Flex Object Type Conversion via ColdSpring</title>
		<link>http://www.fusioncube.net/index.php/coldfusion-flex-object-conversion</link>
		<comments>http://www.fusioncube.net/index.php/coldfusion-flex-object-conversion#comments</comments>
		<pubDate>Thu, 02 Oct 2008 19:26:04 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=250</guid>
		<description><![CDATA[This article covers using the ColdSpring AOP feature to automatically convert ColdFusion queries to an array of value objects for consumption in Flex.  Using value objects (a.k.a. transfer objects) ensure proper data type conversion when passing data from ColdFusion to Flex.]]></description>
			<content:encoded><![CDATA[<h2>The Value Objects</h2>
<p>Otherwise known as a transfer object is simply a design pattern for exchanging data between disparate systems.  I&#8217;m working on a application with a Flex UI and a ColdFusion backend, and I initially discovered that if I return a query directly to Flex, it is converted into an ArrayCollection populated with simple Objects.</p>
<p>What I wanted was an array of specifically typed objects that I could cast as value objects in Flex.  Here&#8217;s a very simplistic example of an Employee value object in Flex. It has two properties:</p>
<ul>
<li>Employee ID</li>
<li>Employee Name</li>
</ul>
<h3>Flex Employee Value Object</h3>
<pre class="code"><code>package net.fusioncube.transferObjects
{
   [RemoteClass(alias="net.fusioncube.model.employee.Employee")]
   [Bindable]
   public class Employee
   {
      private var _employeeID:uint;
      private var _employeeName:String;

      /* constructor */
      public function Effort(employee_id:uint = 0,
                  employee_name:String = "")
      {
         this._employeeID= employee_id;
         this._employeeName= employee_name;
      }

        public function get employee_id():uint
        {
        	return _employeeID;
        }

        public function set employee_id(value:uint):void
        {
        	if(value != 0) _employeeID= value;
        }

        public function get employee_name():String
        {
        	return _employeeName;
        }

        public function set employee_name(value:String):void
        {
        	if(value != "") _employeeName= value;
        }
   }
}</code></pre>
<p>You may have noticed the <strong>RemoteClass</strong> metadata applied to the Actionscript class.  What this does is ensure that this Flex class maps directly to a ColdFusion component value object.  To make a ColdFusion component value object is simple: you use the &lt;cfproperty&gt; tag for each property and specify each one&#8217;s type.</p>
<p>In this example, I&#8217;ve also added an init() method, whose use we&#8217;ll discover later.</p>
<h3>ColdFusion Employee Value Object</h3>
<pre class="code"><code>&lt;cfcomponent displayname="Employee" output="false"&gt;
   &lt;cfproperty name="employee_id" type="numeric" default="" /&gt;
   &lt;cfproperty name="employee_name" type="string" default="" /&gt;

   &lt;cffunction name="init" access="public" returntype="net.fusioncube.model.employee.Employee" output="false"&gt;
      &lt;cfargument name="employee_id" type="numeric" required="false"  /&gt;
      &lt;cfargument name="employee_name" type="string" required="false"  /&gt; 

      &lt;cfset this['effort_id']       = arguments.effort_id /&gt;
      &lt;cfset this['employee_name']      = arguments.employee_name /&gt;

      &lt;cfreturn this /&gt;
   &lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<h2>Converting a Query to an Employee Array</h2>
<p>Again, as a very simple example, let&#8217;s say I have an EmployeeService component in my service layer and have a method listEmployees() that simply queries the <em>employees</em> table and returns all rows.</p>
<pre class="code"><code>&lt;cffunction name="listEmployees" access="public" output="false" returntype="query"&gt;
   &lt;cfset var effortQuery = "" /&gt;

   &lt;cfquery datasource="#variables.config.getSetting("datasource")#" name="employeeQuery"&gt;
   select e.* from employees e
   &lt;/cfquery&gt;

   &lt;cfreturn effortQuery /&gt;
&lt;/cffunction&gt;</code></pre>
<p>Since I don&#8217;t want to return a query, and I certainly don&#8217;t want to have two methods in every single component &#8211; one that returns a query and one that returns an array of objects &#8211; I use the handy, dandy AOP feature in ColdSpring to apply an advice that does it at runtime. </p>
<h3>QueryToVOAdvice Advice</h3>
<p>In this advice, I simply loop over the query&#8217;s rows and columns to create a simple structure containing the key/value pairs for each row.  It then creates a new component for each query row by passing that structure to the init() function &#8211; which you saw above &#8211; and adds it to an array.</p>
<p>The result is an array of Employee-typed objects.</p>
<pre class="code"><code>&lt;cfcomponent displayname="QueryToVOAdvice" extends="coldspring.aop.MethodInterceptor"&gt;

   &lt;cffunction name="init" returntype="utility.aop.advice.converters.QueryToVOAdvice" access="public" output="false"&gt;
      &lt;cfreturn this /&gt;
   &lt;/cffunction&gt;

   &lt;cffunction name="invokeMethod" access="public" returntype="any"&gt;
      &lt;cfargument name="methodInvocation" type="coldspring.aop.MethodInvocation" required="false" /&gt;

      &lt;cfscript&gt;
      var local = structNew();
      local.queryRow = 1;

      // Create an array to hold the value objects
      local.valueObjectArray = ArrayNew(1);

      // Store the resulting query object from the method execution
      local.queryObject = arguments.methodInvocation.proceed();

      // Loop over the query rows
      for(local.queryRow=1; local.queryRow lte local.queryObject.recordCount; local.queryRow = local.queryRow+1)
      {
         local.voStruct = structNew();

         // Loop over the query columns and create a key/value pair for each value
         // in this row of the query
         for(local.columnNum=1; local.columnNum lte listLen(local.queryObject.columnList); local.columnNum = local.columnNum+1)
         {
            local.columnName = listGetAt(local.queryObject.columnList, local.columnNum);
            local.voStruct[local.columnName] = local.queryObject[local.columnName][local.queryRow];
         }

         // Create an instance of the value object (obtained from the getValueObject method)
         // initializing it with the structure we created.  Add the value object to the array.
         arrayAppend(local.valueObjectArray, createObject('component', arguments.methodInvocation.getTarget().getValueObject()).init(argumentCollection=local.voStruct));
      }

      return local.valueObjectArray;
      &lt;/cfscript&gt;
   &lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<h3>ValueObject Property</h3>
<p>For each of my beans, in this case the Employee bean, I can simply apply an advice in the definition.  For this to work, I create a <strong>valueObject</strong> property in each component.</p>
<pre class="code"><code>&lt;component name="Employee"&gt;
   &lt;cffunction name="setValueObject" access="public" output="false" returntype="void"&gt;
      &lt;cfargument name="valueObject" type="string" required="true" /&gt;
      &lt;cfset variables.valueObject = arguments.valueObject /&gt;
   &lt;/cffunction&gt;

   &lt;cffunction name="getValueObject" access="public" output="false" returntype="string"&gt;
      &lt;cfreturn variables.valueObject /&gt;
   &lt;/cffunction&gt;
&lt;/component&gt;</code></pre>
<h3>Employee Bean Definition</h3>
<p>Now when I define my Employee bean, I specify the type of the value object (the type that gets returned from the init() function), and then apply the advisor (shown below).</p>
<pre class="code"><code>&lt;bean id="Employee" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
   &lt;property name="target"&gt;
      &lt;bean class="net.fusioncube.model.employee.EmployeeService"&gt;
         &lt;property name="valueObject"&gt;
            &lt;value&gt;net.fusioncube.model.employee.Employee&lt;/value&gt;
         &lt;/property&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;queryToValueObjectAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<h3>QueryToValueObjectAdvisor Definition</h3>
<pre class="code"><code>&lt;bean id="queryToValueObjectAdvisor" class="coldspring.aop.support.RegexMethodPointcutAdvisor"&gt;
   &lt;property name="advice"&gt;
      &lt;bean class="utility.aop.advice.converters.QueryToVOAdvice"/&gt;
   &lt;/property&gt;
   &lt;property name="pattern"&gt;
      &lt;value&gt;^list.*$&lt;/value&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<h3>The Flex Array of Typed Objects</h3>
<p>Here&#8217;s an image of an example array I get back from ColdFusion in one of my current apps.  You can see that each object was automatically converted into a Teammate (equivalent of an Employee) rather than a simple Object.</p>
<p><a href='http://www.fusioncube.net/wp-content/uploads/2008/10/transferobject_array.png'><img src="http://www.fusioncube.net/wp-content/uploads/2008/10/transferobject_array.png" alt="" title="Array of value objects" width="365" height="189" class="alignnone size-full wp-image-251" /></a></p>
<p>Caveat: If you&#8217;re passing back queries with a thousand or more rows, and are running CFMX 7 or older, then this solution may cause serious performance problems as object creation is notoriously &#8220;slow&#8221; in those versions of ColdFusion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldfusion-flex-object-conversion/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When to use autowiring in ColdSpring</title>
		<link>http://www.fusioncube.net/index.php/when-to-use-autowiring-in-coldsprin</link>
		<comments>http://www.fusioncube.net/index.php/when-to-use-autowiring-in-coldsprin#comments</comments>
		<pubDate>Mon, 15 Sep 2008 19:38:23 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[model-glue]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=248</guid>
		<description><![CDATA[Autowiring in ColdFusion Most of you may have heard of autowiring, and many of you may have implemented it in an application by now (most likely with Spring, ColdSpring, or Google Guice). If you don&#8217;t know what autowiring is, or are curious about how to do it, I&#8217;ll simply direct you to other people who [...]]]></description>
			<content:encoded><![CDATA[<h3>Autowiring in ColdFusion</h3>
<p>Most of you may have heard of autowiring, and many of you may have implemented it in an application by now (most likely with <a href="http://www.springframework.org/">Spring</a>, <a href="http://www.coldspringframework.org/">ColdSpring</a>, or <a href="http://code.google.com/p/google-guice/">Google Guice</a>).</p>
<p>If you don&#8217;t know what autowiring is, or are curious about how to do it, I&#8217;ll simply direct you to other people who have adequately explained it (see reference links at bottom of article) rather than doing it myself.  This article is about when to use it, not how to use it.</p>
<p>Most people I talk to, or have read articles by, promote autowiring as a positive thing.  It offers an effective way to automatically inject instantiated components into other components that require their methods.  Who wouldn&#8217;t be a fan of that??</p>
<p>Nevertheless, there are gadflies who point out that the overuse of autowiring defeats one of the benefits of your bean definition file: a documentation tool.  It is the one place in your application that clearly shows how services depends on each other.  I believe this is a valid point, as I often use my definition file as a quick reference to my application&#8217;s dependencies.</p>
<h3>Autowiring Incidental Dependencies</h3>
<p>I prefer to use the autowiring feature for beans that are not business logic:</p>
<ul>
<li>Datasources</li>
<li>Configuration settings</li>
<li>Resource libraries (e.g. Transfer ORM)</li>
<li>Transfer/Value objects</li>
</ul>
<p>For example, several of my apps are written using Model-Glue, and I define beans to pass the application&#8217;s datasource, and transfer service:</p>
<pre class="code"><code>&lt;bean id="datasource" factory-bean="transfer" factory-method="getDatasource" /&gt;
&lt;bean id="transferService" factory-bean="transfer" factory-method="getTransfer" /&gt;</code></pre>
<p>Most of my beans require one, or both, of these services, and I&#8217;m reluctant to pass them in as constructor arguments since I consider them incidental dependencies, rather than logical dependencies.  I see no benefit in having these clutter up my definition file since they offer no help to me, or anyone else, when determining if the Facility component requires the use of the Organization_Demographics component or not.</p>
<p>Instead of having dozens of these definitions filling up my definition file:</p>
<pre class="code"><code>&lt;bean id="DrugMapping" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
   &lt;property name="target"&gt;
      &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailService"&gt;
         &lt;constructor-arg name="transfer"&gt;
            &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="Offering"&gt;
            &lt;ref bean="Offering" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="Party"&gt;
            &lt;ref bean="Party" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="DetailGateway"&gt;
            &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailGateway"&gt;
               &lt;constructor-arg name="transfer"&gt;
                  &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
               &lt;/constructor-arg&gt;
               &lt;constructor-arg name="datasource"&gt;
                  &lt;bean factory-bean="transfer" factory-method="getDatasource" /&gt;
               &lt;/constructor-arg&gt;
            &lt;/bean&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="datasource"&gt;
            &lt;bean factory-bean="transfer" factory-method="getDatasource" /&gt;
         &lt;/constructor-arg&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<p>Instead I enjoy looking at a definition file that shows me how I&#8217;m wiring my application together.</p>
<pre class="code"><code>&lt;bean id="DrugMapping" class="coldspring.aop.framework.ProxyFactoryBean" autowire="byName"&gt;
   &lt;property name="target"&gt;
      &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailService"&gt;
         &lt;constructor-arg name="Offering"&gt;
            &lt;ref bean="Offering" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="Party"&gt;
            &lt;ref bean="Party" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="DetailGateway"&gt;
            &lt;bean class="&amp;appCFCMapping;.model.request.item.drug.DetailGateway" autowire="byName" /&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<h3>Reference Links</h3>
<p><a href="http://www.firemoss.com/post.cfm/ModelGlue--What-the-hell-is-autowiring">Joe Rinehart on autowiring</a><br />
<a href="http://aria-media.com/blog/index.cfm/2006/9/22/The-Mystery-of-AutoWiring">Nando demystifies autowiring</a><br />
<a href="http://rachaelandtom.info/node/1453">Download a small, sample app that provides autowiring code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/when-to-use-autowiring-in-coldsprin/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The ColdFusion ServiceRunner &#8211; Part I</title>
		<link>http://www.fusioncube.net/index.php/the-coldfusion-servicerunner-part-1</link>
		<comments>http://www.fusioncube.net/index.php/the-coldfusion-servicerunner-part-1#comments</comments>
		<pubDate>Wed, 27 Aug 2008 22:54:19 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=244</guid>
		<description><![CDATA[I&#8217;ve been meaning to share this for many reasons, but I&#8217;ve been bogged down with projects lately. However, it has allowed the code to mature and get streamlined a bit, so it&#8217;s good that some time has passed. This is a pattern that we&#8217;ve come up with at work to handle remote calls to ColdFusion. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to share this for many reasons, but I&#8217;ve been bogged down with projects lately. However, it has allowed the code to mature and get streamlined a bit, so it&#8217;s good that some time has passed.</p>
<p>This is a pattern that we&#8217;ve come up with at work to handle remote calls to ColdFusion. It is one part of our SOA initiative that allows ColdFusion and Flex developers to make service calls to our core business components using a common approach.</p>
<p>I&#8217;ll start at the high level and work my way down.  The reason I started this project is because early on I started to notice that there were many common entities used throughout the gamut of application used by my business unit &#8211; Facilities, Teammates, Drugs, Treatments, Patients, Doctors, etc&#8230;</p>
<p>Each application developer had written their own code to handle retrieving information on each of these entities.  I&#8217;m sure you can see where the problem is in that, so I won&#8217;t belabor the point.  To stop the fragmentation, I began diagramming how to create a common service application that could be accessed by any client in the company using a simple interface.</p>
<h3>The Remote Call Service &#8211; RemotingService.cfc</h3>
<p>Let&#8217;s start off with the first part of the puzzle: the simple interface for calling ColdFusion Component methods in our service application.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;

	&lt;cffunction name="invokeService" access="remote" returntype="Any"&gt;
		&lt;cfargument name="eventName" type="string" required="true" /&gt;
		&lt;cfargument name="eventData" type="struct" required="false" default="#structNew()#" /&gt;

		&lt;cfreturn application.beanFactory.getBean("ServiceRunner").run(argumentCollection=arguments) /&gt;
	&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<p>Can&#8217;t get more simple than this.  Using any remoting technology supporting SOAP, any client can invoke this component&#8217;s invokeService() method.  This is the one entry point into our service application. As I&#8217;m sure you noticed by the <strong>application.beanFactory</strong> code, we&#8217;re using ColdSpring to manage all of our dependencies, AOP features, and event maps (more on this later).</p>
<h3>The Service Response Value Object &#8211; ResponseVO.cfc</h3>
<p>The next concept we tackled was not returning complex objects; we wanted a simple and logical structure to what gets returned to the client.  Also we didn&#8217;t want the response object sitting around in memory sucking up RAM on the machine.  We wanted this object to be created and destroyed on each remote request (shows below in the ServiceRunner code).</p>
<p>What got created was a simple Value Object that defines the keys of the response: name of the event, a success boolean, the data object, and an error structure (which is only populated if an error occurs).</p>
<pre class="code"><code>&lt;cfcomponent output="false"
	hint="Value object that is returned for every response"&gt;

	&lt;cfproperty name="eventName"  type="string" /&gt;
	&lt;cfproperty name="success"    type="boolean" /&gt;
	&lt;cfproperty name="data"       type="any" /&gt;
	&lt;cfproperty name="error"      type="Struct"/&gt;

	&lt;cfset this.eventName = "" /&gt;
	&lt;cfset this.success = true /&gt;
	&lt;cfset this.data = "" /&gt;
	&lt;cfset this.error = structNew() /&gt;

&lt;/cfcomponent&gt;</code></pre>
<h3>The Service Runner &#8211; ServiceRunner.cfc</h3>
<p>Once we&#8217;d defined how services would be called and what the response would be, we then had to write the mechanism to actually execute the method and populate the response VO.  The service runner is defined as a bean via ColdSpring (shown below) and is instantiated from the RemotingService component (shown above).  </p>
<p>The RemotingService then calls the public run() method which creates a VO, executes the requested event using the private runEvent() method, and then returns the populated VO.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;

	&lt;cffunction name="run" access="public" returntype="Any" output="false" description="Responds to remote request"&gt;
		&lt;cfargument name="eventName" type="string" required="true" /&gt;
		&lt;cfargument name="eventData" type="Struct" required="false" default="#structNew()#" /&gt;

		&lt;cfset var local = StructNew() /&gt;
		&lt;cfset var vo = createObject("component", "utility.remoting.ResponseVO") /&gt;

		&lt;cfset vo.success 	= true /&gt;
		&lt;cfset vo.eventName = arguments.eventName /&gt;

		&lt;cftry&gt;
			&lt;cfset local.eventData = arguments.eventData /&gt;

			&lt;cfif application.beanFactory.containsBean("event.#arguments.eventName#")&gt;
				&lt;cfset vo.data = runEvent(eventName=arguments.eventName, eventData=arguments.eventData) /&gt;
			&lt;cfelse&gt;
				&lt;cfthrow detail="Event definition not found" message="event.#arguments.eventName# was not found." /&gt;
			&lt;/cfif&gt;

			&lt;cfcatch type="any"&gt;
				&lt;cfset vo.success 	= false /&gt;
				&lt;cfset vo.data 		= "" /&gt;
				&lt;cfset vo.error 	= cfcatch /&gt;
			&lt;/cfcatch&gt;
		&lt;/cftry&gt;

		&lt;cfreturn vo /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="runEvent" access="private" returntype="any" output="false" hint="Calls the event defined in the EventMaps definition file"&gt;
		&lt;cfargument name="eventName" type="string" required="true" /&gt;
		&lt;cfargument name="eventData" type="Struct" required="true" /&gt;

		&lt;cfset var local = structNew() /&gt;
		&lt;cfset local.response = "" /&gt;

		&lt;cfset local.eventInfo = application.beanFactory.getBean("event.#arguments.eventName#") /&gt;
		&lt;cfset local.eventHandler = application.beanFactory.getBean(local.eventInfo.getBeanName()) /&gt;

		&lt;cfinvoke component="#local.eventHandler#" method="#local.eventInfo.getMethodName()#" returnvariable="local.response" argumentcollection="#arguments.eventData#" /&gt;

		&lt;cfreturn local.response /&gt;
	&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<h3>Defining Events as Beans &#8211; EventMaps.xml</h3>
<p>To define our events, we create a bean for each one using the RemoteEventMap.cfc as the template for each one. The RemoteEventMap (code shown below) has two properties: beanName and methodName.  These are used in the runEvent() method of the ServiceRunner (shown above) to obtain the properties needed for the CFINVOKE tag that executes the actual method we need.</p>
<pre class="code"><code>&lt;!DOCTYPE beans SYSTEM "ColdSpring.dtd"
[
   &lt;!ENTITY appName "yourAppName"&gt;
   &lt;!ENTITY appCFCMapping "&amp;appName;.model"&gt;
   &lt;!ENTITY eventCFCMap "utility.remoting.RemoteEventMap"&gt;
]&gt;
&lt;beans&gt;
   &lt;bean id="ServiceRunner" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
      &lt;property name="target"&gt;
         &lt;bean class="utility.remoting.ServiceRunner" /&gt;
      &lt;/property&gt;
      &lt;property name="interceptorNames"&gt;
         &lt;list&gt;
            &lt;value&gt;metricsAdvisor&lt;/value&gt;
         &lt;/list&gt;
      &lt;/property&gt;
   &lt;/bean&gt;

   &lt;bean id="event.getFacilities" class="&amp;eventCFCMap;"&gt;
      &lt;property name="beanName"&gt;
         &lt;value&gt;FacilityService&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="methodName"&gt;
         &lt;value&gt;getHeldFacilities&lt;/value&gt;
      &lt;/property&gt;
   &lt;/bean&gt;
&lt;/beans&gt;</code></pre>
<h3>The Event Bean &#8211; RemoteEventMap.cfc</h3>
<p>This is the simple RemoteEventMap that each event creates as a bean.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;

	&lt;cffunction name="init" access="public" output="false" returntype="RemoteEventMap"&gt;
		&lt;cfset variables.beanName = "" /&gt;
		&lt;cfset variables.methodName = "" /&gt;

		&lt;cfreturn this /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="getBeanName" access="public" output="false" returntype="string"&gt;
		&lt;cfreturn variables.beanName /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="setBeanName" access="public" output="false" returntype="void"&gt;
		&lt;cfargument name="beanName" type="string" required="true" /&gt;

		&lt;cfset variables.beanName = arguments.BeanName /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="getMethodName" access="public" output="false" returntype="string"&gt;
		&lt;cfreturn variables.methodName /&gt;
	&lt;/cffunction&gt;

	&lt;cffunction name="setMethodName" access="public" output="false" returntype="void"&gt;
		&lt;cfargument name="methodName" type="string" required="true" /&gt;

		&lt;cfset variables.methodName = arguments.methodName /&gt;
	&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</code></pre>
<p>In Part II &#8211; which I will hopefully finish up tomorrow &#8211; I will show implementation examples of this pattern for ColdFusion and for Flex.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/the-coldfusion-servicerunner-part-1/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ColdSpring Low-Fat Double Inner-Bean Latte</title>
		<link>http://www.fusioncube.net/index.php/coldspring-low-fat-double-inner-bean-latte</link>
		<comments>http://www.fusioncube.net/index.php/coldspring-low-fat-double-inner-bean-latte#comments</comments>
		<pubDate>Wed, 16 Jul 2008 14:13:41 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[coldspring]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=241</guid>
		<description><![CDATA[I don&#8217;t know, when I was thinking about a name for the post, all the terms I was coming up with made me think of those coffee freaks at StarBucks ordering their custom cup o&#8217; Joe. Anyway, just wanted to share something that made my ColdSpring.xml file much cleaner and easier to manage/read. I use [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know, when I was thinking about a name for the post, all the terms I was coming up with made me think of those coffee freaks at StarBucks ordering their custom cup o&#8217; Joe.</p>
<p>Anyway, just wanted to share something that made my ColdSpring.xml file much cleaner and easier to manage/read.  I use the AOP feature of <a href="http://www.coldspringframework.org/">the ColdSpring framework</a> to add logging advice to my most heavily used components. This led to many, many, many beans in my config file as I had one for the gateway, one for the service and one for the proxy factory which wrapped around the service.</p>
<pre class="code"><code>&lt;bean id="VialDetailGateway" class="charm.model.request.item.vial.VialDetailGateway"&gt;
	&lt;constructor-arg name="transfer"&gt;
		&lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
	&lt;/constructor-arg&gt;
&lt;/bean&gt;

&lt;bean id="VialDetailTarget" class="charm.model.request.item.vial.VialDetailService"&gt;
	&lt;constructor-arg name="transfer"&gt;
		&lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
	&lt;/constructor-arg&gt;
	&lt;constructor-arg name="VialDetailGateway"&gt;
		&lt;ref bean="VialDetailGateway"/&gt;
	&lt;/constructor-arg&gt;
	&lt;constructor-arg name="datasource"&gt;
		&lt;bean factory-bean="transfer" factory-method="getDatasource" /&gt;
	&lt;/constructor-arg&gt;
&lt;/bean&gt;

&lt;bean id="VialDetail" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
       &lt;property name="target"&gt;
		&lt;ref bean="VialDetailTarget" /&gt;
       &lt;/property&gt;
       &lt;property name="interceptorNames"&gt;
		&lt;list&gt;
			&lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
		&lt;/list&gt;
       &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<p>Then a few months ago, I was trolling the <a href="http://groups.google.com/group/coldspring-users/">ColdSpring discussion boards</a> and came across a post from <a href="http://www.barneyb.com/barneyblog/">Barney Boisvert</a> where <a href="http://groups.google.com/group/coldspring-users/browse_thread/thread/9473b5969df9218b">he mentions that he uses anonymous inner beans</a> when creating the AOP proxy in order to prevent the creation of the actual service component.</p>
<p>It sounded like a good idea, so after implementing that, it reduced the amount of bean definitions in my config file by, you guessed it, 33%.</p>
<pre class="code"><code>&lt;bean id="VialDetailGateway" class="charm.model.request.item.vial.VialDetailGateway"&gt;
   &lt;constructor-arg name="transfer"&gt;
      &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
   &lt;/constructor-arg&gt;
&lt;/bean&gt;

&lt;bean id="VialDetail" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
   &lt;property name="target"&gt;
      &lt;bean class="charm.model.request.item.vial.VialDetailService"&gt;
         &lt;constructor-arg name="transfer"&gt;
            &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="VialDetailGateway"&gt;
            &lt;ref bean="VialDetailGateway"/&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="datasource"&gt;
            &lt;bean factory-bean="transfer" factory-method="getDatasource" /&gt;
         &lt;/constructor-arg&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
<p>Then it hit me today. I never directly access my gateway components, since there is a method in the service component that proxies each gateway method. If I don&#8217;t use the gateway beans, I thought, why on Earth don&#8217;t I just make them inner beans of the service definition?</p>
<p>In the end, I&#8217;ve reduced the amount of bean definitions by, you guessed right again, 66% and now just have one bean definition for each component.  Nice and clean, just the way I like it.</p>
<pre class="code"><code>&lt;bean id="VialDetail" class="coldspring.aop.framework.ProxyFactoryBean"&gt;
   &lt;property name="target"&gt;
   &lt;bean class="charm.model.request.item.vial.VialDetailService"&gt;
         &lt;constructor-arg name="transfer"&gt;
            &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="VialDetailGateway"&gt;
            &lt;bean class="charm.model.request.item.vial.VialDetailGateway"&gt;
               &lt;constructor-arg name="transfer"&gt;
                  &lt;bean factory-bean="transfer" factory-method="getTransfer" /&gt;
               &lt;/constructor-arg&gt;
            &lt;/bean&gt;
         &lt;/constructor-arg&gt;
         &lt;constructor-arg name="datasource"&gt;
            &lt;bean factory-bean="transfer" factory-method="getDatasource" /&gt;
         &lt;/constructor-arg&gt;
      &lt;/bean&gt;
   &lt;/property&gt;
   &lt;property name="interceptorNames"&gt;
      &lt;list&gt;
         &lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
      &lt;/list&gt;
   &lt;/property&gt;
&lt;/bean&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldspring-low-fat-double-inner-bean-latte/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invoking ColdSpring beans with ajaxCFC</title>
		<link>http://www.fusioncube.net/index.php/invoking-coldspring-bean-with-ajaxcfc</link>
		<comments>http://www.fusioncube.net/index.php/invoking-coldspring-bean-with-ajaxcfc#comments</comments>
		<pubDate>Tue, 20 May 2008 16:07:43 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[ajaxCFC]]></category>
		<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=216</guid>
		<description><![CDATA[As a heavy user of Rob Gonda&#8217;s ajaxCFC library, I&#8217;ve incorporated it into almost every app I&#8217;ve written in the past two years. The only restriction that required me to write workarounds was the fact that you could only invoke ColdFusion Components directly. The thing is, I also love ColdSpring to manage dependencies and to [...]]]></description>
			<content:encoded><![CDATA[<p>As a heavy user of Rob Gonda&#8217;s <a href="http://ajaxcfc.riaforge.org/">ajaxCFC</a> library, I&#8217;ve incorporated it into almost every app I&#8217;ve written in the past two years. The only restriction that required me to write workarounds was the fact that you could only invoke ColdFusion Components directly. The thing is, I also love <a href="http://www.coldspringframework.org/">ColdSpring</a> to manage dependencies and to implement my <a href="http://www.coldspringframework.org/docs/Aspect_Oriented_Programming_w__ColdSpring.htm#Introduction">Aspect Oriented Programming</a> components.</p>
<p>What I want is to be able to call my ColdSpring beans with ajaxCFC so that I can make my asynchronous calls, get serialized data back, and all the while utilizing the dependencies set up in my beans.  Well, I finally got around to modifying Rob&#8217;s code to allow for this. I use the jQuery branch, so my solution currently only works for that implementation.  I may try to work on the DWR version, but that&#8217;s unlikely because I don&#8217;t use it.</p>
<p>There are three changes to how you invoke ajaxCFC in order to work with ColdSpring beans.</p>
<h3>The URL Attribute</h3>
<p>Instead of the URL value being the path to your logic component, its value should be the path to the ajax.cfc component</p>
<pre class="brush: jscript; title: ; notranslate">
url:'com/company/common/ajax/ajax.cfc'
</pre>
<h3>The Bean Attribute</h3>
<p>This property&#8217;s value will be the name of the ColdSpring bean you want to use.</p>
<pre class="brush: jscript; title: ; notranslate">
bean: 'Facility'
</pre>
<h3>The Factory Attribute</h3>
<p>This property&#8217;s value will be the name of your ColdSpring bean factory.</p>
<pre class="brush: jscript; title: ; notranslate">
factory:'application.beanFactory'
</pre>
<h3>A Complete Invocation</h3>
<p>Here&#8217;s a sample call stripped directly from one of my applications</p>
<pre class="brush: jscript; title: ; notranslate">
$.AjaxCFC({
	url:'com/company/common/ajax/ajax.cfc',
	bean: 'Facility',
	factory:'application.beanFactory',
	method: 'getFacilities',
	data: { 'orderby':orderByField },
	useDefaultErrorHandler: false,
	success: function(results) {
		$('#facilitySelectContainer').html(results);
	},
	error: function(results) {
		Ext.MessageBox.alert('Error Notification', 'There was an error while loading the facilities. Please try again.')
	}
});
</pre>
<h3>The Code</h3>
<p>There are two files you need to replace.</p>
<ol>
<li>ajax.cfc</li>
<li>jquery.AjaxCFC.js</li>
</ol>
<p><a href='http://www.fusioncube.net/wp-content/uploads/2008/05/ajaxcfc-coldspring.zip' title='ColdSpring-enabled ajaxCFC'>Download ColdSpring-enabled ajaxCFC</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/invoking-coldspring-bean-with-ajaxcfc/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ColdSpring Remote Proxies as WebServices&#8230; Whew!</title>
		<link>http://www.fusioncube.net/index.php/coldspring-remote-proxies-as-webservices-whew</link>
		<comments>http://www.fusioncube.net/index.php/coldspring-remote-proxies-as-webservices-whew#comments</comments>
		<pubDate>Tue, 11 Mar 2008 20:59:48 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[cfml]]></category>
		<category><![CDATA[coldspring]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=202</guid>
		<description><![CDATA[You know the word caveat, right? Well, today I learned that there are a few caveats when setting up ColdSpring remote proxy beans. When invoking a webservice that has logically optional arguments, you still have to pass all defined arguments with the omit attribute set to yes on the &#60;cfinvokeargument&#62; tag (see Listing 1.1 below). [...]]]></description>
			<content:encoded><![CDATA[<p>You know the word caveat, right? Well, today I learned that there are a few caveats when <a href="http://www.coldspringframework.org/docs/Developing_w__ColdSpring.htm#Using_AOP_to_create_remote_proxies">setting up ColdSpring remote proxy beans</a>.</p>
<ul>
<li>When invoking a webservice that has logically optional arguments, you still have to pass all defined arguments with the <strong>omit</strong> attribute set to yes on the &lt;cfinvokeargument&gt; tag (see Listing 1.1 below). Otherwise you&#8217;ll get the result of a Java method exception. It will look something like this &#8211; &#8221; Web service operation &#8220;someMethod&#8221; with parameters {ARGUMENT={1}} could not be found&#8221;</li>
<li>When you have optional arguments in a component method that you want to access as a webservice, you have to provide a default value for each one. Otherwise, you&#8217;ll get <em>premature end of file</em> Axis errors (see Listing 1.2 below)</li>
<li>You must define the (somewhat) undocumented <strong>beanFactoryName</strong> property of ColdSpring&#8217;s RemoteFactoryBean. This will be the package name of where your ColdSpring definitions are located in the application namespace. For those using Model-Glue, this will be <strong>{app name}.framework</strong> (see Listing 1.3 below)</li>
</ul>
<h3>Listing 1.1</h3>
<pre class="code"><code>&lt;cfscript&gt;
billGroupService = createObject("webservice", "http://localhost/webapps/charm/remote/BillingGroup.cfc?wsdl");
&lt;/cfscript&gt;
&lt;cfinvoke method="getGroups" webservice="#billGroupService#"&gt;
	&lt;cfinvokeargument name="BILLING_RULE_GRP_CD" value="1"&gt;
	&lt;cfinvokeargument name="DESCR" <strong>omit="yes"</strong>&gt;
	&lt;cfinvokeargument name="ACTIVE_IND" <strong>omit="yes</strong>"&gt;
	&lt;cfinvokeargument name="DEFAULT_FLAG" <strong>omit="yes"</strong>&gt;
&lt;/cfinvoke&gt;</code></pre>
<h3>Listing 1.2</h3>
<pre class="code"><code>&lt;cffunction name="getGroups" access="public" output="false" returntype="array"&gt;
	&lt;cfargument name="BILLING_RULE_GRP_CD" <strong>default=""</strong> type="string" required="false" /&gt;
	&lt;cfargument name="DESCR" <strong>default=""</strong> type="string" required="false" /&gt;
	&lt;cfargument name="ACTIVE_IND" <strong>default=""</strong> type="string" required="false" /&gt;
	&lt;cfargument name="DEFAULT_FLAG" <strong>default=""</strong> type="string" required="false" /&gt;

	&lt;cfreturn variables.GroupGateway.getByAttributes(argumentCollection=arguments) /&gt;
&lt;/cffunction&gt;</code></pre>
<h3>Listing 1.3</h3>
<pre class="code"><code>&lt;bean id="RemoteBillingRuleGroup" class="coldspring.aop.framework.RemoteFactoryBean"&gt;
	&lt;property name="interceptorNames"&gt;
		&lt;list&gt;
			&lt;value&gt;exceptionLoggingAdvisor&lt;/value&gt;
			&lt;value&gt;metricsAdvisor&lt;/value&gt;
		&lt;/list&gt;
	&lt;/property&gt;
	&lt;property name="target"&gt;
		&lt;ref bean="BillingRuleGroupTarget" /&gt;
	&lt;/property&gt;
	&lt;property name="serviceName"&gt;
		&lt;value&gt;BillingGroup&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="relativePath"&gt;
		&lt;value&gt;/webapps/charm/remote/&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="<strong>beanFactoryName</strong>"&gt;
		&lt;value&gt;<strong><em>charm.framework</em></strong>&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="remoteMethodNames"&gt;
		&lt;value&gt;*&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/coldspring-remote-proxies-as-webservices-whew/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

