<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">

			<channel>
			<title>ArgumentCollection - Broadchoice Engineering - Broadchoice Shares Knowledge</title>
			<link>http://blog.broadchoice.com/index.cfm</link>
			<description>The Broadchoice engineering team blog.</description>
			<language>en-us</language>
			<pubDate>Mon, 06 Sep 2010 13:36:26 -0400</pubDate>
			<lastBuildDate>Sat, 14 Mar 2009 19:05:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>ac@broadchoice.com</managingEditor>
			<webMaster>ac@broadchoice.com</webMaster>
			<itunes:subtitle></itunes:subtitle>
			<itunes:summary></itunes:summary>
			<itunes:category text="Technology" />
			<itunes:category text="Technology">
				<itunes:category text="Podcasting" />
			</itunes:category>
			<itunes:category text="Technology">
				<itunes:category text="Tech News" />
			</itunes:category>
			<itunes:keywords></itunes:keywords>
			<itunes:author></itunes:author>
			<itunes:owner>
				<itunes:email>ac@broadchoice.com</itunes:email>
				<itunes:name></itunes:name>
			</itunes:owner>
			<itunes:image href="" />
			<image>
				<url></url>
				<title>ArgumentCollection - Broadchoice Engineering</title>
				<link>http://blog.broadchoice.com/index.cfm</link>
			</image>
			<itunes:explicit>no</itunes:explicit>
			
			
			
			
			
			<item>
				<title>Transfer ORM and memory usage</title>
				<link>http://blog.broadchoice.com/index.cfm/2009/3/14/Transfer-ORM-and-memory-usage</link>
				<description>
				
				Some people - myself included - have observed runaway memory usage and apparent memory leaks with applications built with certain combinations of CFML frameworks that include Transfer ORM. We spent a lot of time tuning the JVM and looking at code and database usage in our Broadchoice Community Platform (CMS), we worked with Mike Brunt on load testing and tuning (highly recommended - if you have any performance problems, get Mike on your case!) as well as working with Mark Mandel directly on Transfer itself. All that work led to a much more stable system and we decided to just continue investigating as a background task.
				 [More]
				</description>
						
				
				<category>Transfer</category>				
				
				<category>ColdFusion</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Sat, 14 Mar 2009 19:05:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2009/3/14/Transfer-ORM-and-memory-usage</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Broadchoice Community Platform 2.0.11 Released</title>
				<link>http://blog.broadchoice.com/index.cfm/2009/3/11/Broadchoice-Community-Platform-2011-Released</link>
				<description>
				
				As I Twittered on Monday, the new release of the &lt;a
href=&quot;http://www.broadchoice.com/products/community_platform/&quot;&gt;Broadchoice Community Platform&lt;/a&gt; (our hosted content management system) was in QA and had hit zero bugs. QA completed successfully so today we pushed the new release to production. It&apos;s mostly a bug fix and minor enhancements release but it contains one new feature I wanted to talk about from a technical point of view.

The Community Platform has a number of &quot;modules&quot; (applications) that you can add to a page and one of those is a list of documents for download (or external links). You add the module to the page and then select documents (from your document library) to add to that module. In previous releases, authors had to add documents in the order that they wanted them to appear on the (generated) web page. We looked at a number of UI options for allowing authors to &quot;rank&quot; the documents within the module but felt most of them were fairly clunky, involving entering ranking numbers to reorder things or up/down arrows requiring authors to move documents one position at a time. Ugh!

Ray pointed me at one of the cool &lt;a href=&quot;http://jqueryui.com/&quot;&gt;jQuery UI&lt;/a&gt; interactions: sortable. It allows you to mark a &quot;container&quot; tag (e.g., a div) as sortable and then users can drag&apos;n&apos;drop the &quot;child&quot; elements into the order they want. You can attach event handlers that fire at various points in the drag&apos;n&apos;drop operation.

Here&apos;s how we do it:
&lt;code&gt;
&lt;div id=&quot;sortable&quot;&gt;
  &lt;cfloop query=&quot;documents&quot;&gt;
    &lt;div id=&quot;doctag_#documents.id#&quot; onMouseOver=&quot;setCursor(this,&apos;move&apos;)&quot; onMouseOut=&quot;setCursor(this,&apos;auto&apos;)&quot;&gt;
      #documents.name# ... etc ...
    &lt;/div&gt;
  &lt;/cfloop&gt;
&lt;/div&gt;
&lt;/code&gt;
That&apos;s all you need in the HTML. Then you add the following JavaScript:
&lt;code&gt;
$(&apos;#sortable&apos;).sortable({
  update: function(event,ui) {
    jQuery.get(&apos;/updateRank.cfm?&apos; + $(&apos;#sortable&apos;).sortable(&apos;serialize&apos;));
}
&lt;/code&gt;
This causes two things to happen:
&lt;ol&gt;
&lt;li&gt;jQuery marks the sortable div contents as being, well, sortable!&lt;/li&gt;
&lt;li&gt;jQuery adds an event handler for update - when the drag&apos;n&apos;drop operation completes - that invokes a URL on the server, passing in the serialized data from the children of the sortable div, i.e., the id values as a list in the new order: doctag[]=1,3,4,2. It assumes an underscore as a separator.&lt;/li&gt;
&lt;/ol&gt;
The server side code simply updates the module data to put the documents in the specified order.
				
				</description>
						
				
				<category>Tools and Technology</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Wed, 11 Mar 2009 19:04:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2009/3/11/Broadchoice-Community-Platform-2011-Released</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Custom Getters and Flex Remoting &quot;gotcha&quot;</title>
				<link>http://blog.broadchoice.com/index.cfm/2009/2/27/Custom-Getters-and-Flex-Remoting-gotcha</link>
				<description>
				
				I ran into an interesting bug in the final stages of preparing the latest release of the &lt;a href=&quot;http://www.broadchoice.com/&quot;&gt;Broadchoice Workspace&lt;/a&gt; application. I had added a custom getter to an ActionScript object to calculate a complex property, along these lines:
&lt;code&gt;
public function get complexProperty() : SomeType
{
	performSomeCalculation()
	return someComplicatedExpression
}
&lt;/code&gt;
This allows you to say &lt;tt&gt;myObj.complexProperty&lt;/tt&gt; without needing parentheses for a function call (and with a matching custom setter, you can assign to the pseudo-property as well). It&apos;s a nice feature of ActionScript that can really make your code much more readable.

The particular getter I added was only valid when certain data in the object was non-null. In all of the mainline use cases inside the application, this was fine. The &lt;tt&gt;complexProperty&lt;/tt&gt; was only ever accessed after testing the condition on the object:
&lt;code&gt;
if ( myObject.someCondition )
{
	doStuffWith( myObject.complexProperty )
}
&lt;/code&gt;
Yes, &lt;tt&gt;someCondition&lt;/tt&gt; was a custom getter as well.

The bug I ran into was that sometimes remote calls involving this object silently failed. I didn&apos;t get a fault back. It was almost like the call just didn&apos;t happen. Puzzled, I fired up the Flex Debugger (which is absolutely awesome!) and traced through the code. No visible exceptions, no strange paths being executed in the code. More puzzled, I fired up JBoss in the Java Debugger under Eclipse and put a breakpoint inside the server method that was called. Strangely, the code ran without hitting the breakpoint! That showed that the call really was not happening for some reason.

Back in the Flex Debugger, I set a breakpoint just before the remote call and took a very close look at the object in the Variables panel when I hit the breakpoint. It showed the custom getter as a property on the object (as expected) but the value in the debugger showed an exception was thrown retrieving the property. Then it hit me: Flex Remoting tries to serialize the object by calling the getters and it was failing due to the exception - and silently swallowing the exception without telling me, and without executing the remote call!

I updated the getter to return a default value if the condition (&lt;tt&gt;myObject.someCondition&lt;/tt&gt;) was false and, sure enough, the object serialized just fine and the remote call was successfully executed!

Moral of the story: if you add custom getters to ActionScript objects, make sure they cannot throw an exception when the object is in a state where you need to send it to the server using Flex Remoting!
				
				</description>
						
				
				<category>Flex</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<category>BlazeDS</category>				
				
				<pubDate>Fri, 27 Feb 2009 20:15:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2009/2/27/Custom-Getters-and-Flex-Remoting-gotcha</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>ColdFusion in the Cloud Revisited</title>
				<link>http://blog.broadchoice.com/index.cfm/2009/1/9/ColdFusion-in-the-Cloud-Revisited</link>
				<description>
				
				About a month ago, I talked about &lt;a href=&quot;http://blog.broadchoice.com/index.cfm/2008/12/13/ColdFusion-in-the-Cloud-and-clustering&quot;&gt;my experience of setting up clustered ColdFusion instances on EC2&lt;/a&gt;. Since then we have migrated the Broadchoice Web Platform completely from a regular data center, where it had lived since launch, to the Amazon cloud and now all of the *.broadchoice.com sites and all of our client sites based on the Web Platform are happily running in the cloud.

We&apos;ve been very pleased with the performance and stability of EC2 so far and we&apos;re comfortable about scaling out as demand increases. We took advantage of Amazon&apos;s EBS (Elastic Block Storage) that allows you to mount S3 storage directly as part of the file system on EC2. This essentially replaces the NAS we were using in the data center where all uploaded files were placed. We run two ColdFusion instances on a medium EC2 instance and run MySQL on a separate EC2 instance (actually on the instance that is currently running our AIR application, the &lt;a href=&quot;http://www.broadchoice.com/&quot;&gt;Broadchoice Workspace for Salesforce&lt;/a&gt;, along with its MySQL database). We replicate the MySQL databases to another server (in a data center) so that we can restore / recover in the event of a problem with EC2. We also run scheduled backups of the EC2 instances to S3.

As I noted in my earlier entry, we&apos;re using Apache and the JRun Connector to manage the two instance cluster and failover. I&apos;m still suspicious of the connector due to past experience but so far it has been behaving well and when we restart instances for maintenance, we&apos;re generally seeing uninterrupted service, from a user&apos;s point of view, as requests silently failover to the other instance.

If you&apos;re interested in running ColdFusion in the cloud, you&apos;ll need to talk to Adobe about licensing (either Adam Lehman or Kristen Schofield) but they are being very encouraging because they want this to happen. The more of us who do this, the better the argument they can present internally to get the EULA changed to support ColdFusion running in the cloud!

If you want to learn more about how we handled the migration and/or what to watch out for when designing applications that run well on the cloud, feel free to &lt;a href=&quot;http://blog.broadchoice.com/contact.cfm&quot;&gt;contact me&lt;/a&gt; via this blog or directly (c&apos;mon, you know my email address!).
				
				</description>
						
				
				<category>ColdFusion</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Fri, 09 Jan 2009 16:23:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2009/1/9/ColdFusion-in-the-Cloud-Revisited</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Recentering Flex Alerts on Application Resize</title>
				<link>http://blog.broadchoice.com/index.cfm/2009/1/5/Recentering-Flex-Alerts-on-Application-Resize</link>
				<description>
				
				I recently had a bit of a challenge to tackle with our &lt;a href=&quot;http://www.broadchoice.com/what_is_workspace/&quot; target=&quot;_blank&quot;&gt;Workspace&lt;/a&gt; application and thought I would share some details. As many of you probably know from trying out the application, Workspace is meant to be kept open to fully capitalize on it&apos;s collaborative features. The application provides a lot of behavior that is based on real-time communication, such as content being updated or users being added to Spaces. All of this works quite well right now, and we are already working on more features as well as some simplification of the interface to allow new users to get up and running more quickly.

We have, however, noticed a small but annoying glitch that happens as a result of certain real-time notifications that trigger Flex Alerts. Namely, if the application is minimized and an Alert is triggered, when the application is maximized, the Alert does not appear in the proper place. Normally, an Alert will automatically center itself in the window where it appears. But if the application is minimized, this centering does not happen. So when the app is maximized again, the modal Alert is located far in the upper left corner of the screen, with most of it&apos;s content off the screen completely. Users had a hard time figuring out what was happening, and since the Alert is modal, the app can&apos;t be used until the Alert is closed. This resulted in a lot of confused users!

I set out to solve this issue by triggering a re-centering of any open Alerts when the application is resized, but this turned out to be more difficult than it first appears. At first, this seemed like it should be fairly simple: the Flex SystemManager object contains a property called popUpChildren, which references any PopUp objects that are open. So no problem, right? Just loop over this list and recenter them.

In a frustrating turn of events, Flex Alert objects are not stored in this list. I&apos;m not sure why, but they aren&apos;t. This seems like an oversight or bug, but the fact remains that looking at the popUpChildren wouldn&apos;t work. This list appears to only contain any PopUp instances created using the PopUpManager, but not any Alert instances. Nor is there a similar list such as alertChildren. It turns out that Alerts are added to the SystemManager&apos;s display list but are not actually kept track of anywhere.

The first part of the solution was to add an application resize event handler that loops through all children of the SystemManager&apos;s display list and locates any that are instances of the Alert class:

&lt;code&gt;
var systemManager : SystemManager = Application.application.systemManager;

// Look for children of SystemManager that are Alerts, and recenter them.
for ( var i:int = 0; i &amp;lt; systemManager.numChildren; i++ )
{
	var thisChild : Object = systemManager.getChildAt( i );
	if( thisChild is Alert )
	{
		PopUpManager.centerPopUp( thisChild as IFlexDisplayObject );
	}
}
&lt;/code&gt;

This code actually does work and will recenter the Alert. But in another frustrating turn (and what certainly appears to be another bug), the re-centered Alerts did not display correctly. Any text within the Alert box that was &quot;off the screen&quot; prior to re-centering would not display. I tried triggering an invalidateDisplayList() and invalidateProperties(), but nothing would get the Alert to re-draw the text correctly. I was banging my head against the monitor when my astute colleague Joe Rinehart made a suggestion that turned out to give the desired result:

&lt;code&gt;
var systemManager : SystemManager = Application.application.systemManager;

// Look for children of SystemManager that are Alerts, and recenter them.
for ( var i:int = 0; i &amp;lt; systemManager.numChildren; i++ )
{
	var thisChild : Object = systemManager.getChildAt( i );
	if( thisChild is Alert )
	{
		PopUpManager.removePopUp( thisChild as IFlexDisplayObject );
		PopUpManager.addPopUp( thisChild as IFlexDisplayObject, this );
		PopUpManager.centerPopUp( thisChild as IFlexDisplayObject );
	}
}
&lt;/code&gt;

Essentially, you have to kick Flex in the head by removing the Alert, re-adding it, and then re-centering it for good measure. All of this seems like a lot of hoops to jump through to accomplish something that seems like it should be rather easy to do, but there you have it. Going forward, we&apos;ll probably set up some sort of centralized manager class that can be used to create and keep track of both Alerts, PopUps, and any other components that need to display at the very top display list of the application (such as Callouts and Tooltips), and we&apos;re also looking at some Growl-like notifications to minimize the use of Alerts. But that&apos;s a topic for another day (probably in the very near future though). In any event, hopefully this post will help anyone who ends up in a similar situation!
				
				</description>
						
				
				<category>Flex</category>				
				
				<category>Workspace</category>				
				
				<category>AIR</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Mon, 05 Jan 2009 11:51:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2009/1/5/Recentering-Flex-Alerts-on-Application-Resize</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Unit Testing Improves Your Love Life</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/11/26/Unit-Testing-Improves-Your-Love-Life</link>
				<description>
				
				Oh, sorry, that was the title of the BACFUG presentation by Bill Shelton and Marc Esher (of MXUnit fame)!

Unit testing has defined my working day. I&apos;ve been working on the licensing subsystem of the next build of the &lt;a href=&quot;http://www.broadchoice.com/what_is_workspace/&quot;&gt;Broadchoice Workspace&lt;/a&gt; today and because we practice Test-Driven Development (thanx Brian!), that means writing unit tests &quot;first&quot; or at least alongside the production code.

I started by writing the License bean and an accompanying LicenseTest. The bean has a handful of properties and two methods. The unit test has nine test methods.

Fairly confident that the bean was correct, I moved on to the data layer. Apart from encryption, this mostly follows our well-tested generic Hibernate DAO. That meant only a couple of unit tests.

Once those tests passed, I moved on to the service layer. Six unit tests for four service methods.

At this point I&apos;m ready to write the remote service facade (which implements user-level security) but I&apos;m fairly confident our licensing subsystem will work as expected. 623 lines of code, just over half of which is unit tests (327 lines to 296 production code). I&apos;ll probably add some more data layer unit tests since I have a couple of &quot;untested&quot; methods (they&apos;re used in the service layer tests).

Unit tests may seem dull and tedious but they really can make your life easier.
				
				</description>
						
				
				<category>Tools and Technology</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Wed, 26 Nov 2008 04:06:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/11/26/Unit-Testing-Improves-Your-Love-Life</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Some Code Statistics for Broadchoice Workspace</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/11/14/Some-Code-Statistics-for-Broadchoice-Workspace</link>
				<description>
				
				Now that the &lt;a href=&quot;http://www.broadchoice.com/what_is_workspace/&quot; target=&quot;_blank&quot;&gt;Broadchoice Workspace&lt;/a&gt; has been officially released, I thought I&apos;d post a quick entry with some code statistics. I ran the codebase through a line counting tool that gives a breakdown by file, folder, language, etc. We all know that lines of code is not a very good way to judge quality or effort, but it is still interesting in a general way. This is only lines of code, all blank lines and comments were excluded:

&lt;ul&gt;
&lt;li&gt;Total Lines of Code: 50,125&lt;/li&gt;
&lt;li&gt;Total Files: 633&lt;/li&gt;
&lt;li&gt;Lines of MXML: 10,784&lt;/li&gt;
&lt;li&gt;Lines of ActionScript: 12,675&lt;/li&gt;
&lt;li&gt;Lines of CFML: 7,730&lt;/li&gt;
&lt;li&gt;Lines of Groovy: 8,878&lt;/li&gt;
&lt;li&gt;Lines of XML: 1,757&lt;/li&gt;
&lt;li&gt;Lines of CSS, HTML, JavaScript, etc.: 7,612&lt;/li&gt; 
&lt;li&gt;Lines of SQL: 1,089&lt;/li&gt;
&lt;li&gt;Lines excluded as comments or blank: 15,778&lt;/li&gt;
&lt;/ul&gt;
				
				</description>
						
				
				<category>Workspace</category>				
				
				<category>General</category>				
				
				<category>Tools and Technology</category>				
				
				<category>AIR</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Fri, 14 Nov 2008 20:10:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/11/14/Some-Code-Statistics-for-Broadchoice-Workspace</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Email Testing on OSX</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/11/11/Email-Testing-on-OSX</link>
				<description>
				
				Yesterday I &lt;a href=&quot;http://blog.broadchoice.com/index.cfm/2008/11/10/Plain-Text-and-HTML-Emails-via-Spring&quot;&gt;blogged&lt;/a&gt; about how I set up Groovy/Spring to send both HTML and plain text emails. Today I want to share a tip about testing those emails. I was using postfix on my Mac as SMTP server. This allowed Spring to connect to, and send the email, but the emails would never leave my machine. My coworker Sean had no problem with mail getting out, so I figured I either had some setting wrong or perhaps it was my cable company blocking the traffic.

I googled around a bit and came across this excellent blog article: &lt;a href=&quot;http://traumwind.de/tindertraum/archives/local_mail_osx.html&quot;&gt;fully local testing of email sending web apps (on Mac OS X)&lt;/a&gt;

This article describes how to set up postfix to listen to certain domain names and forward those emails to local account. It then goes on to describe how you can setup a pop3 server to get those mails.

The end result is that you can send email to &lt;i&gt;anything&lt;/i&gt; at a particular domain and then use a desktop client to check the mail. This is not only cool for Groovy work but would also be useful for ColdFusion as well. I normally use &lt;a href=&quot;http://spoolmail.riaforge.org&quot;&gt;Spoolmail&lt;/a&gt; to check CFML generated mail, but that isn&apos;t an option for Railo, and it doesn&apos;t give a &apos;perfect&apos; end user view of the mail (especially for combo plain text/html emails like we are testing).
				
				</description>
						
				
				<category>Spring</category>				
				
				<category>ColdFusion</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Tue, 11 Nov 2008 13:05:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/11/11/Email-Testing-on-OSX</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Is it ColdFusion or Groovy?</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/11/3/Is-it-ColdFusion-or-Groovy</link>
				<description>
				
				Here at &lt;a href=&quot;http://www.broadchoice.com&quot;&gt;Broadchoice&lt;/a&gt; we&apos;ve been working on our &lt;a href=&quot;http://blog.broadchoice.com/index.cfm/2008/9/7/Behind-The-Curtain&quot;&gt;new product&lt;/a&gt; for close to three months now. I&apos;ve gotten a crash course in Groovy, Spring, and Hibernate, all of which are slightly familiar to me from my time with ColdSpring, Transfer, and Java. I&apos;m really digging these new technologies, but of course, I&apos;m a die hard ColdFusion user at heart. A few weeks backs I needed to work on a quick iPhone web application prototype. Joe set up the connection and all I had to do was write CFML (lucky me). Little did I know that along with setting up basic CFML compatibility on the server, Joe also added one of the slickest things I&apos;ve seen ever in my life as a developer.

The application I&apos;m working on is pretty simple, but I wanted to use Model-Glue 3 for it since - well - you never know when a simple prototype will turn into a large, complex application. The following code snippet comes from a controller used to load bookmarks:

&lt;code&gt;
    &lt;cffunction name=&quot;getBookmarks&quot; output=&quot;false&quot;&gt;
        &lt;cfargument name=&quot;event&quot; /&gt;
        &lt;cfset var u = arguments.event.getValue(&quot;currentuser&quot;)&gt;
       
        &lt;!--- In theory currentuser should always exist, but... ---&gt;
        &lt;cfif not isSimpleValue(u)&gt;
            &lt;!--- space only? ---&gt;
            &lt;cfif arguments.event.valueExists(&quot;space&quot;)&gt;
                &lt;cfset arguments.event.setValue(&quot;bookmarks&quot;, beans.contentService.findContentBySpace(arguments.event.getValue(&quot;space&quot;),[&quot;Bookmark&quot;]))&gt;
            &lt;cfelse&gt;
                &lt;cfset arguments.event.setValue(&quot;bookmarks&quot;, beans.contentService.findUsersContent(u,[&quot;Bookmark&quot;]))&gt;
            &lt;/cfif&gt;
        &lt;/cfif&gt;
           
    &lt;/cffunction&gt;
&lt;/code&gt;
      
Nothing in the above code should be too odd or even that exciting really. I&apos;m using a service (injected via the beans scope in Model-Glue 3) to retrieve my content. My controller begins with...

&lt;code&gt;
&lt;cfcomponent output=&quot;false&quot; hint=&quot;I am a Model-Glue controller.&quot; extends=&quot;ModelGlue.gesture.controller.Controller&quot;
    beans=&quot;contentService,config&quot;
&gt;
&lt;/code&gt;

Note the beans value specifies which beans configured in ColdSpring should be passed to my controller. I love this new automation in Model-Glue 3. If you open up my ColdSpring.xml file, you will see my beans configured:

&lt;code&gt;
&lt;bean id=&quot;config&quot; class=&quot;ModelGlue.Bean.CommonBeans.SimpleConfig&quot;&gt;
    &lt;property name=&quot;config&quot;&gt;
        &lt;map&gt;
            &lt;entry key=&quot;profileimageroot&quot;&gt;&lt;value&gt;/some url you dont need to know&lt;/value&gt;&lt;/entry&gt;
            &lt;entry key=&quot;filesroot&quot;&gt;&lt;value&gt;/something else you dont need to worry about&lt;/value&gt;&lt;/entry&gt;
            &lt;entry key=&quot;perpage&quot;&gt;&lt;value&gt;10&lt;/value&gt;&lt;/entry&gt;           
        &lt;/map&gt;
    &lt;/property&gt;
&lt;/bean&gt;   
&lt;/code&gt;

Hmmm. Ok, there&apos;s my config bean, wheres my contentService bean? Oh yeah - here it is:

&lt;code&gt;
    &lt;bean id=&quot;contentService&quot; class=&quot;com.broadchoice.bcp.services.ContentService&quot;&gt;
        &lt;property name=&quot;dao&quot; ref=&quot;contentDAO&quot;/&gt;
        &lt;property name=&quot;sessionFacade&quot; ref=&quot;sessionFacade&quot; /&gt;
        &lt;property name=&quot;sharedFileGateway&quot; ref=&quot;sharedFileGateway&quot; /&gt;
        &lt;property name=&quot;eventMessageDispatcher&quot; ref=&quot;eventMessageDispatcherService&quot; /&gt;
    &lt;/bean&gt;
&lt;/code&gt;

You can find the above in our Spring file. Just in case the above didn&apos;t quite make get through, let me make it real nice and obvious:

&lt;code&gt;
&lt;cfset arguments.event.setValue(&quot;bookmarks&quot;, beans.contentService.findContentBySpace(arguments.event.getValue(&quot;space&quot;),[&quot;Bookmark&quot;]))&gt;
&lt;/code&gt;

The above line of CFML is using a bean injected from Spring, not ColdSpring, and points to a Groovy file. This is the same Groovy code used to drive the AIR application. No createObject(&quot;java&quot;) here baby. I&apos;m using the Groovy code just like it had come from a CFC. This is done using a ColdSpring/Spring adapter that Joe wrote. It lets ModelGlue get Java-based beans from Spring. (I&apos;m simplifying it here a bit, but hopefully you get the significance of that!) Once that connection is done, you can easily get beans from the Spring file and inject them into your controller. So for example, when my UserController wanted do handle login, I added: beans=&quot;userService,config&quot; and then simply ran a userService.validateAndLoad on the authentication information.

It&apos;s always been easy to use Java from CFML, but never has been so sexy! Now to be fair, I did have to use a JavaCast once or twice, but not nearly as much as I would have thought.
				
				</description>
						
				
				<category>Groovy</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<category>ColdSpring</category>				
				
				<category>Spring</category>				
				
				<category>Model-Glue</category>				
				
				<category>Tools and Technology</category>				
				
				<pubDate>Mon, 03 Nov 2008 17:52:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/11/3/Is-it-ColdFusion-or-Groovy</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>AIR File Download Gotcha</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/8/29/AIR-File-Download-Gotcha</link>
				<description>
				
				If you happen to work with Adobe AIR at some point, and you want to download a file from a server, you may run into this helpful error:

I/O error 2038

Not very helpful. After a lot of digging and trying out solutions, I think I&apos;ve figured it out. I was doing something like this in a Delegate object:

&lt;code&gt;
public function downloadFile( fileName:String ):void {
	var req:URLRequest = new URLRequest( this.sharedFileDownloadURL + fileName );
	var file = new File();
	file.addEventListener( Event.COMPLETE, saveCompleteHandler );
	file.addEventListener( IOErrorEvent.IO_ERROR, ioErrorHandler );
	file.download( req, fileName );
}
&lt;/code&gt;

The problem seems to be the scope of the File object that is used to perform the download. Because it is locally scoped to that method, when the download completes and the completion event is announced, the file object is essentially gone. I&apos;m not sure if AIR is garbage collecting it, or if the variable is just not accessible because it is function-scoped. Either way, I got this error over and over and was pulling my hair out.

The solution is to not var scope the new File object. Unfortunately that seems to open up potential concurrency issues. Because the Delegate object is essentially a Singlton, if I add the file as a public property of the Delegate, and more than one upload goes at the same time on the client, it will get overwritten. That&apos;s not good.

I got around it by creating an Object to wrap around my file called SharedFile. This object has a public property which is a File object. In that case, I can do something like this:

&lt;code&gt;
public function downloadFile( sharedFile:SharedFile ):void {
	var req:URLRequest = new URLRequest( this.sharedFileDownloadURL + sharedFile.name );
	sharedFile.file = new File();
	sharedFile.file.addEventListener( Event.COMPLETE, saveCompleteHandler );
	sharedFile.file.addEventListener( IOErrorEvent.IO_ERROR, ioErrorHandler );
	sharedFile.file.download( req, sharedFile.name );
}
&lt;/code&gt;

So I&apos;m setting the sharedFile.file property to a new File, then using that file object to perform the upload. The I/O error vanishes because the file object is not locally-scoped, and so a reference to it still exists when the completion event fires. Again, I&apos;m not sure of the exact underlying cause of the problem, whether a function-scoped file object is simply not visible when the completion event fires, or whether the AIR runtime is garbage collecting the variable before the completion event fires. Either way, this seems to fix it!
				
				</description>
						
				
				<category>Tools and Technology</category>				
				
				<category>AIR</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Fri, 29 Aug 2008 13:42:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/8/29/AIR-File-Download-Gotcha</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>JMS + Swiz = Evil Realtime Flex.</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/8/22/JMS--Swiz--Evil-Realtime-Flex</link>
				<description>
				
				We&apos;re building out some prototype applications here at &lt;a href=&quot;http://www.broadchoice.com&quot;&gt;Broadchoice&lt;/a&gt; based on a Groovy + AIR stack that have multiple cases of data &quot;push&quot; to the AIR client.

At first, we took a traditional route of setting up destinations and Consumers for the different realtime cases, but that got pretty old pretty quickly, and we&apos;ve put together a nifty system using server-side JMS and the &lt;a href=&quot;http://code.google.com/p/swizframework/&quot;&gt;Swiz framework&lt;/a&gt;.  This&apos;d also work with Cairngorm or any other MVC Flex framework that uses a central event dispatcher / front controller.

&lt;em&gt;What&apos;s the architecture?&lt;/em&gt;

Swiz includes the idea of a CentralDispatcher that allows events to be dispatched outside of the UI component tree, allowing controllers (very Model-Glueish!) or even views to listen for application-level events.

On the server side, we&apos;ve created a class (ApplicationEventMessage) that models a request for the client-side to create and dispatch (via Swiz) a DynamicEvent containing arbitrary properties.

By setting up a delegate that uses a Consumer (autowired by Swiz, of course!) the receives pushed ApplicationEventMessage instances to the client, we&apos;re using JMS on the server side to essentially dispatch events on the client side.

&lt;em&gt;What&apos;s the result?&lt;/em&gt;

We&apos;ve got a little controller on the client side subscribed to events of type &quot;notification&quot; that shows a nice little notification overlay in the application.  When a user logs in, we want a notification of this login to get pushed to all other clients.  Instead of setting up a new destination, a new consumer, and all of that rigamarole, we can just dispatch JMS message via the single consumer to send a message to client requesting that a DynamicEvent of type &quot;notification&quot; with a message property of &quot;John Doe logged in&quot; be created and dispatched.  

Here&apos;s all the server-side code I had to write (in Groovy using Spring&apos;s JmsTemplate):

&lt;code&gt;

def message = new ApplicationEventMessage(
	eventType: &quot;notification&quot;,
	data: [
		message: &quot;John Doe logged in&quot;
	]
)
	
jmsTemplate.send(
	[
	 	createMessage: { Object[] params -&gt;
	 		def session = params[0]
	 		return session.createObjectMessage(message)
	 	}
	] as MessageCreator
)

&lt;/code&gt;

Taking it one step further, I wrapped this up in a simple service (wired into other services via Spring) that the rest of the team can use.  For example, Brian Kotek was working  on a small filesharing system and wanted to notify clients of new uploads.  

Here&apos;s literally all he had to do to send out client-side notifications:

&lt;code&gt;
def message = new ApplicationEventMessage(
		type:&quot;fileUploaded&quot;,
		data: [
			message: fileItem.name + &quot; was added to the shared files.&quot;			
		]
)

messageDispatcher.dispatch(message)
&lt;/code&gt;

&lt;em&gt;But Why JMS?&lt;/em&gt;

We&apos;re going to be targeting multiple platforms with some upcoming products.  JMS is by no means Flex-specific, allowing us to use this same notification system to send realtime updates to clients other than Flex and AIR.
				
				</description>
						
				
				<category>Flex</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Fri, 22 Aug 2008 12:13:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/8/22/JMS--Swiz--Evil-Realtime-Flex</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Flex (BlazeDS), JMS, and JBoss in a Nutshell</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/8/20/Flex-BlazeDS-JMS-and-JBoss-in-a-Nutshell</link>
				<description>
				
				This morning, I published another tech doc for folks&apos; use here at &lt;a href=&quot;http://www.broadchoice.com&quot;&gt;Broadchoice&lt;/a&gt; that was appropriate for sharing with the world.  It describes how to configure a topic-style JMS destination within JBoss, connect a BlazeDS destination to it, and have a Flex consumer listen for messages from the BlazeDS destinatin (and therefore the JMS topic).

It&apos;s a Google doc, is available here:

&lt;a href=&quot;http://docs.google.com/View?docid=dcnf3wxn_9dbz5hpch&quot;&gt;Flex (BlazeDS), JMS, and JBoss in a Nutshell&lt;/a&gt;
				
				</description>
						
				
				<category>BlazeDS</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Wed, 20 Aug 2008 13:27:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/8/20/Flex-BlazeDS-JMS-and-JBoss-in-a-Nutshell</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Swiz and MockAsyncToken</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/8/18/Swiz-and-MockAsyncToken</link>
				<description>
				
				I&apos;ve been taking a look at the applicability of Chris Scott&apos;s &lt;a href=&quot;http://code.google.com/p/swizframework/&quot;&gt;Swiz Framework&lt;/a&gt; for use here at &lt;a href=&quot;http://www.broadchoice.com&quot;&gt;Broadchoice&lt;/a&gt;.  So far, it&apos;s exactly what I&apos;d expect - a fairly noninvasive way of wiring dependencies inside a Flex / AIR application that allows use of inversion-of-control.

One thing that threw me, though, was that Swiz approaches business delegates (wrappers for business services like RemoteObjects) from a total RPC standpoint.  Instead of passing an IResponder to a new delegate instance each time you wish to use it like most Flex frameworks encourage, you simply write a delegate, instantiate it once in your BeanLoader, and use it as a singleton.  Each of its methods that make server-side calls just return AsyncToken instances.

I &lt;em&gt;really&lt;/em&gt; like this, as it makes the difference between a simple RemoteObject and a delegate wrapper completely irrelevant - your controller doesn&apos;t have a clue if it&apos;s talking to a delegate or not.

It did, however, throw me off from something I typically do.  I normally write a &quot;mock&quot; delegate for any business service that &quot;pretends&quot; the server is there.  Its useful in both unit tests and day to day coding:  server may be down, backend code not written, etc.  

In order to get this to work with Swiz, however, I had to simulate the presense of an AsyncToken and its related RPC events.  Hence, I&apos;ve cobbled together a MockAsyncToken and MockResultEvent that let you quickly set what you&apos;d like a mock delegate to return:

&lt;code&gt;

// Mock&apos;d RPC function
public function getUser() : AsyncToken
{
 // just pass the desired server response to the MockAsyncToken&apos;s constructor
 return new MockAsyncToken(new User());
}
&lt;/code&gt;

...bam.  Instant mock delegate.  Thanks to Swiz, the rest of the app doesn&apos;t care that it&apos;s even there, and if I can use a plain RemoteObject, I never even have to write the &quot;real&quot; delegate.

Code for MockAsyncToken and MockResultEvent (dependency) is attached.  Use at your own peril.
				
				</description>
						
				
				<category>Flex</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Mon, 18 Aug 2008 13:18:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/8/18/Swiz-and-MockAsyncToken</guid>
				
				<enclosure url="http://blog.broadchoice.com/enclosures/mockasynctoken.zip" length="5881" type="application/x-zip-compressed"/>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Better Living Through Transfer and ColdSpring</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/8/15/Better-Living-Through-Transfer-and-ColdSpring</link>
				<description>
				
				We have a live system with customer data and a new requirement comes along that a particular piece of customer data must be encrypted in the database from now on. We already encrypt some columns (using Triple DES - which you might have guessed given the recent posts on my blog and here about mimicking ColdFusion&apos;s encryption in Java/Groovy). What is the smallest possible code change to ensure that as any user updates their data in future, this item will automatically be encrypted - whilst still handling the case of legacy data being unencrypted?

We use Transfer for all our persistent business objects and almost all of our business objects have a decorator defined (for validation or some additional business logic). We also use Brian&apos;s &lt;a href=&quot;http://coldspringutils.riaforge.org/&quot;&gt;TDOBeanInjectorObserver&lt;/a&gt; to automatically inject services into our business objects - just add a setter for a service and the bean injector takes care of the rest.

Here&apos;s the bean injector definition in our ColdSpring file:
&lt;code&gt;
&lt;bean id=&quot;transferObjectInjector&quot; class=&quot;coldspring.transfer.TDOBeanInjectorObserver&quot;&gt;
	&lt;constructor-arg name=&quot;transfer&quot;&gt;&lt;ref bean=&quot;transfer&quot; /&gt;&lt;/constructor-arg&gt;
	&lt;constructor-arg name=&quot;suffixList&quot;&gt;&lt;value&gt;service,datasource&lt;/value&gt;&lt;/constructor-arg&gt;
	&lt;constructor-arg name=&quot;debugMode&quot;&gt;&lt;value&gt;true&lt;/value&gt;&lt;/constructor-arg&gt;
&lt;/bean&gt;
&lt;/code&gt;
Normally you would declare it non-lazy but we already do other non-lazy initialization so in our ColdSpring factory initialization code, we do this:
&lt;code&gt;
&lt;cfset bf.getBean(&quot;transferObjectInjector&quot;) /&gt;
&lt;/code&gt;
to force the bean injector to be initialized which, in turn, registers itself as a Transfer event listener (so that it can intercept object creation). The &lt;tt&gt;suffixList&lt;/tt&gt; specifies that any &lt;tt&gt;set*Service()&lt;/tt&gt; method or &lt;tt&gt;set*Datasource()&lt;/tt&gt; method on the business objects managed by Transfer should be matched to beans defined in ColdSpring and injected.

So how do we add the on-demand encryption to our business object&apos;s data?
				 [More]
				</description>
						
				
				<category>Tools and Technology</category>				
				
				<category>Transfer</category>				
				
				<category>ColdSpring</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Fri, 15 Aug 2008 22:45:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/8/15/Better-Living-Through-Transfer-and-ColdSpring</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Writing your Second Model-Glue Application</title>
				<link>http://blog.broadchoice.com/index.cfm/2008/8/14/Writing-your-Second-ModelGlue-Application</link>
				<description>
				
				So the title is a bit of a trick. This really isn&apos;t about writing your second Model-Glue application, but more about the kinds of things you see when comparing earlier Model-Glue applications to those you write after having a few under your belt. Most likely a lot of what I&apos;m going to talk about applies to other frameworks as well, so this isn&apos;t just a Model-Glue concern. When I arrived at &lt;a href=&quot;http://www.broadchoice.com&quot;&gt;Broadchoice&lt;/a&gt;, the older version of our product had already been updated to use the Model-Glue framework. The primary developer team behind this update had just learned Model-Glue. A lot of what I saw looked very similar to how I had built Model-Glue sites when I began. Here are a few items to consider when building your next Model-Glue application. 

&lt;b&gt;Model-View-Controller need not be singular...&lt;/b&gt;&lt;br /&gt;
For those of us who were new to MVC, the idea of nicely separating back end logic from front end views was a godsend. Sure it meant a bit more work up front, but the benefits later on were more than worth the effort. I think this is the thing I appreciated the most about MVC. So, like most people, I began to work with a controller, a ModelGlue.xml file, and maybe a few model files and my directory of views. This worked fine for a smaller site, but as the site began to grow, my XML configuration and controller file began to explode. When I needed to find an event, I was scrolling through 1000 lines of XML. Even if I used a nice naming scheme (more on that below), it was a chore to work with. When I began using Model-Glue, there wasn&apos;t a simple solution for this. Luckily the framework added support for XML includes. 

I ran into the same issue with my controller as well. The file had become too large to manage. It didn&apos;t even occur to me to use multiple controllers until I had done a few Model-Glue sites, but now that I have I wouldn&apos;t do it any other way. My typical approach is to break up the controllers by &quot;areas of concern&quot; - which is my way of referring to the major parts of the application. So for example, a typical site may have a User, Product, and News controller. Each would be responsible for handling events related to their areas. So the User controller would handle listening to getUser. Product would listen to getProduct. Etc. 

I still keep a controller named, well, Controller, because I find that there are typically events that don&apos;t fall into any one particular category. I also still put a few events in the main ModelGlue.xml file. 

What&apos;s nice about MVC, and where I think it really &quot;sinks in&quot; for developers new to the concept, is that you can update a Model-Glue site to fix this problem and not lose a drop of functionality. So at Broadchoice, I&apos;ve been slowing breaking things up a bit when there are available cycles. This has zero impact on the product for the end user but has the side effect of making it easier to update the application.

I also recommend breaking up the views folder. It may start small, but before you know it any semi-complex site can grow quite complex. The main idea here is to make it as simple as possible for someone to find the right code when performing updates.

&lt;b&gt;Inconsistent Naming&lt;/b&gt;&lt;br /&gt;
Ok, so this may be more of an issue for those of us who are anal retentive about naming, but I really get bothered when my event names don&apos;t follow a standard naming pattern. Inconsistent naming is an even bigger problem if the files aren&apos;t properly broken up (see above). There are no hard and fast rules for what makes a good event name. My typical rule is &quot;area of concern&quot;.&quot;action&quot;, so I will typically have events like:

&lt;ul&gt;
&lt;li&gt;product.edit
&lt;li&gt;user.authenticate
&lt;li&gt;planet.destroy
&lt;/ul&gt;

This way it&apos;s always clear what type of data (or area of the application) is being worked with, and what type of action is being performed. Once again, the beauty of MVC is that you can make these types of corrections when you have time for it. There are two potential problems with this.

First - you may have existing URLs that rely on certain event names. In the past I&apos;ve handled this by either using a URL rewrite or by catching the &quot;missing event&quot; error in Model-Glue. Model-Glue 3 adds support for handling missing events directly so this will get even cleaner. While you should put some thought into how you name your events, it may make sense to pay extra attention to those events the users will actually see (and possibly bookmark). 

The second problem is a bit harder to fix. If you change the event that is run when a user logs in, it isn&apos;t just enough to update the XML. You also have to remember to update the view layer as well. I was never really a big fan of the XFA technique. This is a Fusebox concept whereby you tell the view what to use for particular events. (I believe this originated with Fusebox - if anyone knows better, speak up!) So instead of me hard coding action=&quot;index.cfm?event=user.authenticate&quot; in the form tag, I&apos;d pass it to the view layer and make the action dynamic. After doing some refactoring on our product, which made heavy use of XFAs in Model-Glue, I&apos;m really happy they were used. Here is a simple example from one of our views:

&lt;code&gt;
&lt;views&gt;
	&lt;view name=&quot;body&quot; template=&quot;documents/documents.cfm&quot; append=&quot;true&quot;&gt;
		&lt;value name=&quot;xe.view&quot; value=&quot;document.document.view&quot; /&gt;
		&lt;value name=&quot;xe.list&quot; value=&quot;Documents&quot; /&gt;
		&lt;value name=&quot;xe.edit&quot; value=&quot;document.document.edit&quot; /&gt;
	&lt;/view&gt;
&lt;/views&gt;
&lt;/code&gt;

Note the use of the value subkey inside the view node. This will add the values to the viewState. You would then use these when creating any links within the view.

&lt;b&gt;Anything else?&lt;/b&gt;&lt;br /&gt;
This is - in general - the big things I&apos;ve noticed when looking at first generation Model-Glue sites. I&apos;m curious to see what others have discovered as well, so please chime in with your comments. 

I&apos;ll add one more thing to the list - I wish like heck I had made more use of auto-wiring and ColdSpring in general. Until you see a good example of an application that uses this you don&apos;t truly get how much work it can save you.
				
				</description>
						
				
				<category>Model-Glue</category>				
				
				<category>Broadchoice Shares Knowledge</category>				
				
				<pubDate>Thu, 14 Aug 2008 18:45:00 -0400</pubDate>
				<guid>http://blog.broadchoice.com/index.cfm/2008/8/14/Writing-your-Second-ModelGlue-Application</guid>
				
			</item>
			
		 	
			</channel></rss>