<?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; recommended</title>
	<atom:link href="http://www.fusioncube.net/index.php/category/recommended/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>The World Is Changing &#8211; The New Landscape for Application Development</title>
		<link>http://www.fusioncube.net/index.php/the-world-is-changing-the-new-landscape-for-application-development</link>
		<comments>http://www.fusioncube.net/index.php/the-world-is-changing-the-new-landscape-for-application-development#comments</comments>
		<pubDate>Wed, 15 Jun 2011 13:47:50 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[recommended]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[emerging]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[trend]]></category>
		<category><![CDATA[virtual machine]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=1263</guid>
		<description><![CDATA[The world of application development is a constantly evolving landscape. New tools are constantly being created to make development fast, easier and more profitable. For the last two years, I've been seeing a new trend emerge. It's something that I believe will be the landscape of application development for the next 10 years, and it's been right under everyone's nose the entire time.]]></description>
			<content:encoded><![CDATA[<p>&#8220;&#8230;<a href="http://en.wikiquote.org/wiki/Talk:The_Lord_of_the_Rings_(movies)" target="_blank">I feel it in the water, I feel it in the earth, I smell it in the air</a>&#8230;&#8221;</p>
<p>Like you, I have a wide range of development experience. In the past 20 years, I&#8217;ve been a huge fan of Java, C#, Flex (Actionscript), ColdFusion, F#, Ruby and Python. In fact, a few years ago in my last job, myself and some colleagues spent a significant amount of time and effort convincing everyone to migrate to Flex-based applications (they have since decided to migrate yet again to .NET). At the time, it was the right move.</p>
<p>Now I would never suggest such a migration</p>
<p>Feel free to disagree with the following opinion, but from what I&#8217;ve been seeing over the past couple of years is&#8230;</p>
<p>JavaScript is going to be the virtual machine that drives the next 10 years of software evolution. </p>
<p>Not all software, mind you. I&#8217;m talking about the revolution that&#8217;s going on in mobile, cross-platform, cloud-based computing and development.</p>
<p>Now, what exactly do I mean by that? JavaScript itself is not a virtual machine, it&#8217;s simply a programming syntax, right? Well, that&#8217;s true, but remember that the companies writing JavaScript engines are making virtual machines &#8211; such as <a href="http://code.google.com/p/v8/" target="_blank">Google&#8217;s V8</a> &#8211; that parse and execute JavaScript&#8230; and they&#8217;re fast. In fact, they are becoming so fast, that JavaScript is slowly, but surely, becoming a ubiquitous language that not only builds the logic and validations of an application, but is now building the actual user interface, and the brains behind it (see <a href="http://en.wikipedia.org/wiki/Server-side_JavaScript" target="_blank">server side JavaScript</a>). </p>
<p>We&#8217;ll get into that later, but I want to start off with a statement to all the legion .NET, Java, Actionscript, Ruby, Python, {insert language here} developers who look with disdain, or even confusion at JavaScript. You&#8217;re missing it. You&#8217;re missing what&#8217;s going on around you, and for anyone who&#8217;s been in software for even a short amount of time, you learn that you adapt or you risk becoming marginalized.</p>
<p>Let&#8217;s start off with the trends that I&#8217;ve been seeing, and also some nice links that really show off the power of these JavaScript virtual machines. Some are obviously impressive, some are subtly so, but all of them give a taste of what&#8217;s coming.</p>
<h3>Running An Operating System In The Browser</h3>
<p>Start off by checking out <a href="http://bellard.org/jslinux/" target="_blank">Fabrice Bellard&#8217;s PC emulator</a> with the Linux 2.6.20 kernel on it. That&#8217;s right, an operating system running inside a browser.</p>
<p>Imagining the possibilities of utilizing this kind of tool is exciting. Are you an android developer? Imagine writing your code and then being able to emulate the browser-based version of your program <strong>and</strong> the mobile version in the browser &#8211; side by side.</p>
<p>Imagine having a RAM based file system running in the background behind your web application, and using <a href="http://diveintohtml5.org/storage.html" target="_blank">Web Storage</a> to make the environment and experience different for each user &#8211; while never having to communicate with a central server.</p>
<p>How about running a dynamic P2P server inside your browser using <a href="http://dev.w3.org/html5/websockets/" target="_blank">WebSockets</a>?</p>
<p>All written with JavaScript. Impossible? We&#8217;ll see.</p>
<h3>One Language To Rule Them All</h3>
<p>Yes, the LOTR references will continue to pile up as this article goes on, just accept it!</p>
<h4>Appcelerator Titanium</h3>
<p>Some months ago (oh about 6) I stumbled across this tool called <a href="http://www.appcelerator.com/products/" target="_blank">Titanium</a>. The only reason that I learned of its existence is because the developers of my favorite tool &#8211; Aptana IDE &#8211; were acquired by the company Appcelerator. I blithely browsed their web site that day thinking they were just another software development company. However, by the time I was done reading their technology road map, my brain had changed. A light had turned on that hasn&#8217;t been shut off since.</p>
<p>JavaScript can be used to design entire applications, and then be compiled into almost every operating system using the standard SDKs! How is this possible? So if I want to write an application that can be deployed on the desktop (Windows, OSX, or Linux)  and also be deployed to mobile devices <em><strong>as native applications</strong></em> (Android, iOS, Blackberry), I only need one source code library?</p>
<p>The world is changing, indeed.</p>
<h4>Node</h4>
<p>What can I say about <a href="http://en.wikipedia.org/wiki/Node.js" target="_blank">Node.js</a> that hasn&#8217;t been said already? Well, for the uninitiated, Node.js is a program written in C++ that allows you to author server-side services in JavaScript. It is entirely event-driven, on a single thread, and is designed to be a non-blocking I/O framework.</p>
<p>I will not go into any details on it here, but for those who have investigated it, I believe it&#8217;s the tip of the iceberg, and for those who have not, well, then you need to spend a couple hours this weekend going down the rabbit hole.</p>
<p>Node.js still has a long way to go (Windows support <em>*cough*</em>), but since its introduction to the world in November of 2009, there are now <strong>hundreds</strong> of <a href="https://github.com/joyent/node/wiki/modules" target="_blank">modules</a> written for it that will cover most of your interests and needs.</p>
<p>Most impressive so far is a <a href="http://nowjs.com/">module called Now.js</a>. It allows you to have real-time communication between your server and your clients with one simple JavaScript file. If any of you have ever tried to implement message queues in the .NET or Java environments, you know how many hoops you have to jump through, how it affects performance and your system architecture. This module is so easy and painless to implement, it almost made me laugh when I first saw it work.</p>
<p>If you&#8217;re interested, here&#8217;s the <a href="http://jsconf.eu/2009/video_nodejs_by_ryan_dahl.html" target="_blank">original presentation given by Ryan Dahl</a> at the JSConf in 2009.</p>
<h4>Code Complete</h4>
<p>Given these two tools, you can now write your secure, server logic and the entire customer facing application in one language and have it interpreted to any platform. That&#8217;s exciting!</p>
<h3>Dumbing Down To JavaScript</h3>
<p>I&#8217;m sure that&#8217;s how many software developers would term the desire to write a program in Java or C# and then run it through a compiler to generate JavaScript! Gasp! How plebian&#8230; how absurd!</p>
<p>Yet these companies (little ones named Google and Microsoft, respectively) have written these compilers because there&#8217;s a need. First, there&#8217;s the <a href="http://code.google.com/webtoolkit/overview.html" target="_blank">Google Web Toolkit</a> for Java and, secondly, there&#8217;s <a href="http://projects.nikhilk.net/ScriptSharp" target="_blank">Script#</a> for the .NET folks.</p>
<h3>Google</h3>
<p>I have to give a lot of credit to this evolution to Google. Their brilliant engineers have shown us time after time after time that almost anything you think can&#8217;t be done with JavaScript, they have done it. Perfect example. Someone (with an apropos name of Putrid Polecat) commented on Ars Technica story about Windows 8 (see link below) with the following uneducated comment.</p>
<blockquote><p>
Serious applications simply cannot be written in HTML 5 and JavaScript. Continued support for C#/c++/Java must, and therefore will, continue. Can you write adobe illustrator in html5? Blender? AutoCAD? A virtual machine emulator? Device drivers? A compiler? </p>
<p>Cmon guys.
</p></blockquote>
<p>Let&#8217;s see&#8230;</p>
<p>A virtual machine emulator?  Well we covered that.</p>
<p>A compiler? They&#8217;re working on it with <a href="http://code.google.com/p/gettoken/" target="_blank">getToken()</a>. Also, I suppose you could just write your own with <a href="http://jscc.jmksf.com/" target="_blank">JS/CC</a>.</p>
<p>AutoCAD? This one&#8217;s probably right with JavaScript in its current state. Its floating point calculations might not be able to support the precision needed by a CAD program. There&#8217;s <a href="http://www.ecmascript.org/docs/tc39-2009-043.pdf" target="_blank">hope for the future</a>, though.</p>
<p>Adobe Illustrator? There&#8217;s plenty of <a href="http://editor.pixastic.com">online image editors</a> available, but nothing yet as comprehensive as Illustrator.  However, with the HTML5 Canvas, I&#8217;m betting that it&#8217;s coming soon.</p>
<p>Speaking of Google, how about a word processor, or spreadsheet application, or database tool in the browser with JavaScript. <a href="http://docs.google.com" target="_blank">Google Docs</a>.</p>
<p>However, I agree with his core point about there always being a need for compiled, strongly typed languages. I just want people to understand that JavaScript is as powerful as any other language, and used properly, can achieve mind-blowing results.</p>
<p>It is not the Gollum of programming languages, but as these tools show, it is the Gandalf. The one language that can somehow bring all the pieces together in order to develop and distribute applications as quickly and as powerfully as possible.</p>
<h3>The Big Redmond Machine</h3>
<p><a href="http://arstechnica.com/microsoft/news/2011/06/html5-centric-windows-8-leaves-microsoft-developers-horrified.ars">Windows 8 APIs are going to be HTML5 and JavaScript</a>? Well, I don&#8217;t believe that for a second, and the article even ends saying that there&#8217;s more to it and Microsoft will give us more details as time goes by. However, given that a monster, a juggernaut, with the development and marketing power of Microsoft comes out and says that it&#8217;s banking on the latest round of W3C specs for HTML, CSS, WebSockets, Web Storage and JavaScript speaks louder than most everything else.</p>
<p>I think this is a great move on their part. Having C#, C++ developers working hand in hand with the JavaScript developers to build the communication and business layer that will feed the presentation layer is probably how it will all end up (viz Appcelerator above).  But that&#8217;s just a guess.</p>
<blockquote><p>
** Update (09/15/2011) Here&#8217;s a great article that describes <a href="http://www.infoq.com/news/2011/09/Metro-Plug-ins" title="Metro Plugins" target="_blank">Metro Plugins</a> (or, more specifically, the lack thereof) in more detail, and some basic info on the Metro style browser that will be in Windows 8 and why JavaScript and HTML are the basis of that experience.
</p></blockquote>
<h3>Right Under Our Noses The Whole Time</h3>
<p>Raise your hand if you remember the hoopla in the late 90&#8242;s about Java being the write once, run anywhere platform that would liberate us all!!  Go on, raise your hand, no one will notice. Ok, we all remember, and it failed.</p>
<p>Now, raise your hand again if you remember Adobe, and then Microsoft, saying that compiled, vector-based browser plugins are going to allow us to write once, and run anywhere, and it will liberate us all!! Ok, you don&#8217;t need to raise your hand this time, but we all remember (it was just a handful of years ago). It also failed.</p>
<p>Is it possible that, like the gorgeous girl in the movie that no one noticed because she wore glasses and had her hair in a pony tail, the answer was right in front of us and no one saw it? Perhaps Google was the catalyst needed, like the movie bet where the jock dares to turn the nerdy girl into the prom queen, to let us see the true beauty and power of this little toy language written by <a href="http://en.wikipedia.org/wiki/Brendan_Eich" target="_blank">Brendant Eich</a> &#8211; who just so happens to be a native Yinzer (look it up) &#8211; way back in 1995.</p>
<p>The most beautiful thing about it is that JavaScript will be the glue that can tie all of the tools together. You can utilize Java programs and C# assemblies from your Node server, integrate a Flash movie or communicate with a Silverlight application in your UI, and then, just for fun, execute a command on your local, browser-based operating system.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/the-world-is-changing-the-new-landscape-for-application-development/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Creating a Sencha ExtJS paging bar for a DataGrid</title>
		<link>http://www.fusioncube.net/index.php/creating-a-sencha-extjs-paging-bar-for-a-datagrid</link>
		<comments>http://www.fusioncube.net/index.php/creating-a-sencha-extjs-paging-bar-for-a-datagrid#comments</comments>
		<pubDate>Wed, 23 Jun 2010 15:09:15 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[recommended]]></category>
		<category><![CDATA[Sencha]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[pagingbar]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/index.php/creating-a-sencha-extjs-paging-bar-for-a-datagrid</guid>
		<description><![CDATA[True to my promise over the years, anytime it takes me significant mental and time resources to discover how to accomplish a development task that I think others might find useful, I will share the process. I’ve got an app in which users need access to a dataset that is larger than 10k records. Pagination [...]]]></description>
			<content:encoded><![CDATA[<p>True to my promise over the years, anytime it takes me significant mental and time resources to discover how to accomplish a development task that I think others might find useful, I will share the process.</p>
<p>I’ve got an app in which users need access to a dataset that is larger than 10k records. Pagination to the rescue (plus a search feature which I covered in my <a href="http://www.fusioncube.net/index.php/replacing-data-in-extjs-grid-store" target="_blank">Replacing data in Sencha ExtJS grid store</a> article).&#160; I’m giving the users the option of paging through the results 100 at a time if they so wish.</p>
<p>It ended up being simple to accomplish after scouring through the documentation and looking at related articles throughout the Web.</p>
<p>First you need to have a script that returns sets of 100 results. In my case, I have a ColdFusion Component that does a CFQUERY on the table. I simply pass in the number from which I want to start my resultset and it returns the next 100 rows. Convert your query to a JSON string using serializeJSON() in ColdFusion, or any method you wish.</p>
<p>Next, I created a ColdFusion page that accepts a <em>start</em> parameter – which is sent from the PagingBar object in ExtJS – and passes that along to the CFC. The resulting JSON string simply gets output.</p>
<pre class="code"><code>&lt;cfsetting enablecfoutputonly="true"&gt;

&lt;cfparam default="" name="start"&gt;

&lt;cfscript&gt;
providers = application.widget.framework.getBean('Insurance').listInsurance(startRecord=start);
writeOutput(insurers);
&lt;/cfscript&gt;

&lt;cfsetting enablecfoutputonly="false"&gt;</code></pre>
<p>Next, create a Store object with this page as its proxy, and a JsonReader to parse the results.</p>
<pre class="code"><code>var Insurer = Ext.data.Record.create([
       {name: 'col1', type: 'int'},
       {name: 'col2', type: 'string'},
       {name: 'col3', type: 'string'},
       {name: 'col4', type: 'int'}
]);

var InsurerStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({url: 'liveQueries/insurance.cfm'}),
    reader: new Ext.data.JsonReader({ root: 'data', totalProperty:'totalRecords' }, Insurer)
});</code></pre>
<p>Now you can create your PagingBar object with the Store object you created as its datastore.</p>
<pre class="code"><code>var PagingBar = new Ext.PagingToolbar({
    pageSize: 100,
    store: InsurerStore,
    displayInfo: true,
    displayMsg: 'Displaying topics {0} - {1} of {2}',
    emptyMsg: 'No insurers to display'
});</code></pre>
<p>Lastly, attach your PagingBar to a DataGrid object with the <em>bbar</em> property. You also have the option of performing an initial search to show the first 100 record to the user by default. To do this, just call the load() event on your Store (shown below).</p>
<pre class="code"><code>var InsurerGrid = new Ext.grid.GridPanel({
   store             : InsurerStore,
   sm                : new Ext.grid.RowSelectionModel({singleSelect:true}),
   cm                : InsurerColumnModel,
   renderTo          : 'insurer-grid',
   frame             : true,
   bbar              : PagingBar
});

InsurerStore.load({params:{start:0, limit:100}});</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/creating-a-sencha-extjs-paging-bar-for-a-datagrid/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sencha ExtJS Drag &amp; Drop Target Detection</title>
		<link>http://www.fusioncube.net/index.php/extjs-drag-drop-target-detection</link>
		<comments>http://www.fusioncube.net/index.php/extjs-drag-drop-target-detection#comments</comments>
		<pubDate>Tue, 15 Jun 2010 13:49:45 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[recommended]]></category>
		<category><![CDATA[drag and drop]]></category>
		<category><![CDATA[findRowIndex]]></category>
		<category><![CDATA[notifyDrop]]></category>
		<category><![CDATA[Sencha]]></category>
		<category><![CDATA[target element]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/index.php/extjs-drag-drop-target-detection</guid>
		<description><![CDATA[I wanted to enhance the experience on one of my applications a bit since we’re doing a release in a few weeks. I took the opportunity to implement some more ExtJS awesomeness on many of the tools inside the application, and on one in particular, users are able to create 1-1 mappings between two sets [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to enhance the experience on one of my applications a bit since we’re doing a release in a few weeks. I took the opportunity to implement some more ExtJS awesomeness on many of the tools inside the application, and on one in particular, users are able to create 1-1 mappings between two sets of data.</p>
<p>I decided to tinker around with the drag &amp; drop capabilities of ExtJS and originally had the user click a button, which created a window, into which the user could drag an item from each data set and create the mapping. It worked very well and was a much better interaction than the previous version.</p>
<p>I showed it to a colleague, and he actually thought of a way to make it better. Why not simply allow the user to click and drag an item from one grid to the item on the other grid to which she wanted to map it? Even better. However, when I started to think about the code I would need, I couldn’t think of how to determine which item in the “drop” data grid was the actual target.</p>
<p>Let’s say you have automobiles in one grid, and colors in another. You could let the user drag a color from the second grid onto a specific model of vehicle on the first, but the trick is determining onto which model the user dropped the color.</p>
<p><a href="http://www.fusioncube.net/wp-content/uploads/2010/06/clip_image001.png"><img title="clip_image001" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="404" alt="clip_image001" src="http://www.fusioncube.net/wp-content/uploads/2010/06/clip_image001_thumb.png" width="505" border="0" /></a></p>
<p>If I was able to detect the model, I could then show a new window with the requested mapping so that the user could verify her choice.</p>
<p><a href="http://www.fusioncube.net/wp-content/uploads/2010/06/clip_image0015.png"><img title="clip_image001[5]" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="257" alt="clip_image001[5]" src="http://www.fusioncube.net/wp-content/uploads/2010/06/clip_image0015_thumb.png" width="493" border="0" /></a></p>
<p>After some digging around, I discovered that the Grid object’s view has a <em>findRowIndex()</em> method which accepts an Element as an argument. Since the <em>notifyDrop</em> event provides the e.target() property, that was all I needed. I could get the row index, and then retrieve the corresponding item from the data store.</p>
<pre class="code"><code>// Determine the row on which the color was dropped
targetRow = TargetGrid.getView().findRowIndex(e.target);
targetDataItem = TargetGrid.store.data.items[targetRow];</code></pre>
<p>You can check out the sample code that shows how to determine the target grid element on my <a href="http://www.fusioncube.net/examples/ddTarget.html" target="_blank">Drag &amp; Drop Target Detection</a> example page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/extjs-drag-drop-target-detection/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Application and Client Specific Messaging in Flex</title>
		<link>http://www.fusioncube.net/index.php/application-and-client-specific-messaging-in-flex</link>
		<comments>http://www.fusioncube.net/index.php/application-and-client-specific-messaging-in-flex#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:51:08 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[event gateways]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[messaging]]></category>
		<category><![CDATA[recommended]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=706</guid>
		<description><![CDATA[I&#8217;ve had a task I assigned to myself open for some time now. I needed to figure out how to implement Flex/ColdFusion messaging for our clients. There were three (3) criteria for success: It needed to integrate seamlessly with our existing Cairngorm Extensions It needed to allow for application level messages It needed to allow [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a task I assigned to myself open for some time now.  I needed to figure out how to implement Flex/ColdFusion messaging for our clients.  There were three (3) criteria for success:</p>
<ol>
<li>It needed to integrate seamlessly with our existing Cairngorm Extensions</li>
<li>It needed to allow for application level messages</li>
<li>It needed to allow for client specific messages</li>
</ol>
<p>The trick was to create an abstract class that multiple departments could use, because internally we use ColdFusion, Java and .NET to produce and consume messages.  In our department, we use ColdFusion, so I had to create a concrete implementation of the abstract class called ColdFusionMessagingDelegate which handles the construction and publication of an AsyncMessage to a ColdFusion Event Gateway.</p>
<p>Other departments&#8217; implementation of this process will be different, so I couldn&#8217;t force an implementation in the abstract class.</p>
<p>Additionally, in the application I was using for testing, I wanted to have two categories of messages:</p>
<ol>
<li>Messages intended to be produced and consumed by individual clients</li>
<li>Messages intended to be consumed by any client</li>
</ol>
<p>To that end, I created another abstract class at the application level that simply passed along specific a Flex Producer and Consumer for each category. I then created two concrete classes.  One specified the Producer and Consumer for the application, and the other specified the Producer and Consumer for that individual client.</p>
<p>Here&#8217;s a diagram showing the architecture.</p>
<div id="attachment_718" class="wp-caption alignnone" style="width: 762px"><a href="http://www.fusioncube.net/wp-content/uploads/2010/02/GenericMessagingArchitecture.png"><img src="http://www.fusioncube.net/wp-content/uploads/2010/02/GenericMessagingArchitecture.png" alt="Generic Messaging Architecture" title="Generic Messaging Architecture" width="564" height="457" class="size-full wp-image-718" /></a><p class="wp-caption-text">Generic Messaging Architecture</p></div>
<p>So far, it&#8217;s working great in the development test lab, but I still need to get with my colleagues for a group code review and hopefully fine tune the code and the architecture a bit more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/application-and-client-specific-messaging-in-flex/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Flex and ColdFusion Communication via Event Gateways</title>
		<link>http://www.fusioncube.net/index.php/tutorial-flex-and-coldfusion-communication-via-event-gateways</link>
		<comments>http://www.fusioncube.net/index.php/tutorial-flex-and-coldfusion-communication-via-event-gateways#comments</comments>
		<pubDate>Tue, 09 Jun 2009 17:16:11 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[event gateways]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[recommended]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=606</guid>
		<description><![CDATA[How to set up ColdFusion event gateways for communicating with Flex.]]></description>
			<content:encoded><![CDATA[<h1>1&nbsp;&nbsp;&nbsp;Preface</h1>
<p>At work, we&#8217;re investigating using ColdFusion Event Gateways to handle certain complex types of communication between our Flex user interfaces and ColdFusion, so yesterday I jumped on Google and started researching and ran into some <a href="http://www.fusioncube.net/index.php/coldfusion-event-gateway-for-flex-messaging">roadblocks</a>.  However, after some monkeying around and more poring over of documentation and articles, I finally got a basic example working.</p>
<p>As usual, now that I&#8217;ve discovered how to set up a somewhat advanced feature of a platform, I&#8217;m sharing the knowledge in a comprehensive article.  The documentation available for getting ColdFusion and Flex to communicate via event gateways was scattered, incomplete, or incomprehensible.  In many of the articles, there were a lot of words, but little or no code, which does not help developers at all.  Don&#8217;t tell me how it works, SHOW me how it works.</p>
<h1>2&nbsp;&nbsp;&nbsp;Creating a ColdFusion Listener Component</h1>
<p>The listener component is the ColdFusion code that will receive any message sent from your Flex client via the DataServicesMessaging gateway type in your ColdFusion admin (more on that later).  The basic structure is simple &#8211; just need one method named onIncomingMessage() in your component.</p>
<p>Create a file called InterceptFlex.cfc somewhere in your webroot and put the following code in it.</p>
<h3>InterceptFlex.cfc</h3>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;
   &lt;cffunction name="onIncomingMessage" returntype="any"&gt;
         &lt;cfargument name="event" type="struct" required="true" /&gt;

	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;</code></pre>
<h1>3&nbsp;&nbsp;&nbsp;Setting Up Your Event Gateway</h1>
<p>Now you need to go to your ColdFusion Administrator so that you can create an event gateway that specifies that any message coming in on a certain destination will be sent to the InterceptFlex component.</p>
<h2>3.1&nbsp;&nbsp;&nbsp;Destinations</h2>
<p>There is a destination already set up for you in the \WEB-INF\flex\services-config.xml file (or \WEB-INF\flex\messaging-config.xml file if you are running BlazeDS) called ColdFusionGateway, and we&#8217;re just going to use that for this example.</p>
<p>You just need to make one change for this sample application to work.  Open up the XML file and find the ColdFusionGateway destination.  In the &lt;properties&gt; block add the following server property:</p>
<pre class="code"><code>&lt;properties&gt;
   &lt;server&gt;
      &lt;durable&gt;false&lt;/durable&gt;
      &lt;allow-subtopics&gt;true&lt;/allow-subtopics&gt;
   &lt;/server&gt;

   ...
&lt;/properties&gt;</code></pre>
<h2>3.2&nbsp;&nbsp;&nbsp;Gateway Setup</h2>
<p>Now, go to the Gateway Instances section of your ColdFusion Administrator and start creating a gateway.  </p>
<ol>
<li>The gateway ID can be anything, and you can just call it &#8220;test&#8221; for now.</li>
<li>Select <em>DataServicesMessaging</em> as the type.</li>
<li>The CFC path is the physical path to your InterceptFlex.cfc file you created.</li>
<li>the configuration file is located in the <em>\WEB-INF\cfusion\gateway\config\</em> directory, and you can use the one already set up named <em>flex-messaging-gateway.cfg</em>.  So find that file and enter the path here.</li>
<li>Click the <em>Add Gateway Instance</em> button.</li>
<li>Start the gateway instance you just created.</li>
</ol>
<h1>4&nbsp;&nbsp;&nbsp;Sending Messages From Flex</h1>
<p>This application is a slight modification from the code provided in the Adobe article <a href="http://www.adobe.com/devnet/flex/articles/intro_fms.html">Introduction to the Flex Message Service</a>, which I highly recommend you read if you&#8217;re new to Flex Messaging.</p>
<p>Create a new Flex application called <strong>Chat</strong> and paste this code into the <em>Chat.mxml</em> file. This code will connect to the ColdFusionGateway destination and send the message object to ColdFusion.  ColdFusion, in turn, uses the event gateway instance we set up to send that object to the <em>onIncomingMessage()</em> method of the <em>InterceptFlex.cfc</em> component.</p>
<pre class="code"><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
    pageTitle="Simple Flex Chat" creationComplete="createChat()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[

        import mx.messaging.Consumer;
        import mx.messaging.Producer;
        import mx.messaging.events.MessageAckEvent;
        import mx.messaging.events.MessageFaultEvent;
        import mx.messaging.events.MessageEvent;
        import mx.messaging.messages.AcknowledgeMessage;
        import mx.messaging.messages.AsyncMessage;
        import mx.utils.ObjectUtil;

        private var chatPublisher:Producer;
        private var chatSubscriber:Consumer;

        private function createChat():void
        {
            chatPublisher = new Producer();
            chatPublisher.addEventListener(MessageFaultEvent.FAULT, onProducerFault);
            chatPublisher.destination = "ColdFusionGateway";

            chatSubscriber = new Consumer();
            chatSubscriber.addEventListener(MessageAckEvent.ACKNOWLEDGE, onConsumerAck);
            chatSubscriber.addEventListener(MessageEvent.MESSAGE, receiveChatMessage);
            chatSubscriber.destination = "ColdFusionGateway";
            chatSubscriber.subtopic = "simpleChat";
            chatSubscriber.subscribe();
        }

        private function onProducerFault(faultEvent:MessageFaultEvent):void
        {
            output.text += "[Error: " + faultEvent.message.toString() + "]\n";
        }

        private function onConsumerAck(ackEvent:MessageAckEvent):void
        {
            output.text += "[Got ack for subscribe or unsubscribe operation]\n";
        }

        // Note: these are the event-handling methods from above, now moved into the separate source file:

        private function sendChatMessage():void
        {
            var msg:AsyncMessage = new AsyncMessage();
            msg.body = input.text;
            msg.headers["username"] = "Me";
            msg.headers["gatewayid"] = "test";
            chatPublisher.subtopic = "simpleChat";
            chatPublisher.send(msg);
            input.text = "";
        }

        private function receiveChatMessage(msgEvent:MessageEvent):void
        {
            var msg:AsyncMessage = AsyncMessage(msgEvent.message);
            output.text += msg.headers["username"] + ": " + msg.body + "\n";
        }
        ]]&gt;
    &lt;/mx:Script&gt;

    <!-- UI Declarations -->
    &lt;mx:Panel title="Simple Flex Chat"&gt;
        &lt;mx:TextArea id="output" width="500" height="220" /&gt;
        &lt;mx:TextInput id="input" width="500" enter="sendChatMessage()" /&gt;
        &lt;mx:ControlBar horizontalAlign="center" width="500"&gt;
            &lt;mx:Button id="clearBtn" label="Clear" click="output.text =''" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;</code></pre>
<h1>5&nbsp;&nbsp;&nbsp;Respond to the Flex Client</h1>
<p>Now that ColdFusion has received the message, we&#8217;re simply going to respond back.  You can enhance this to do anything you wish &#8211; send out emails, update database tables, log messages &#8211; but for now we&#8217;re just going to send a message back that let&#8217;s the Flex client know that the mechanism works.</p>
<pre class="code"><code>&lt;cfcomponent output="false"&gt;
   &lt;cffunction name="onIncomingMessage" returntype="any"&gt;
      &lt;cfargument name="event" type="struct" required="true" /&gt;

      &lt;cfscript&gt;
      x = structNew();
      x.body = "hello right back at ya";
      x.destination = "ColdFusionGateway";
      x.headers = structNew();
      x.headers['username'] = "System";
      x.headers['DSSubtopic'] = "simpleChat";
      x.lowercasekeys = "yes";
      &lt;/cfscript&gt;

      &lt;cfreturn x /&gt;
   &lt;/cffunction&gt;
&lt;/cfcomponent&gt;</code></pre>
<p>One of those esoteric details that took me forever to find out was how to apply a subtopic to a message in ColdFusion.  In Flex, it&#8217;s absurdly simply, you simply say <em>message.subtopic = &#8220;myTopic&#8221;;</em>, but in ColdFusion, you have to set a header key named DSSubtopic with the topic name (see above).</p>
<h1>6&nbsp;&nbsp;&nbsp;Conclusion</h1>
<p>To be safe, restart your ColdFusion instance, then fire up the simple Flex chat app and type in a message.  After a few seconds, you will receive a message from System in the history box.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/tutorial-flex-and-coldfusion-communication-via-event-gateways/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Sencha ExtJS: Simple Autocomplete Example</title>
		<link>http://www.fusioncube.net/index.php/ext-simple-autocomplete-example</link>
		<comments>http://www.fusioncube.net/index.php/ext-simple-autocomplete-example#comments</comments>
		<pubDate>Mon, 09 Jun 2008 22:03:06 +0000</pubDate>
		<dc:creator>Steve Brownlee</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[Ext]]></category>
		<category><![CDATA[recommended]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[httpproxy]]></category>
		<category><![CDATA[Sencha]]></category>

		<guid isPermaLink="false">http://www.fusioncube.net/?p=222</guid>
		<description><![CDATA[An article to show how to implement the Ext autocomplete ComboBox feature]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s somewhat difficult to find examples of the autocomplete ComboBox that the Ext library provides, so I&#8217;ll add another one to the mix in the hopes that it makes it easier for future implementers to find.</p>
<p>First, let&#8217;s look at the code you need.  The Ext stylesheet and the ext-all.js library.  Then you&#8217;ll need your own, custom interaction code.  My naming convention is to start with <em>interaction</em> and then the page to which the code applies.</p>
<pre class="code"><code>&lt;link href="css/ext-all.css" rel="stylesheet" type="text/css"&gt;

&lt;script type="text/javascript" src="js/ext-all.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/interaction.example.js"&gt;&lt;/script&gt;</code></pre>
<p>This article is going to focus on the <a href="http://extjs.com/deploy/dev/docs/?class=Ext.data.HttpProxy">HTTPProxy</a> code for the autocomplete feature. The one argument you need is URL, and it value will be the name of the file that is actually going to perform the query and return the results. This code is simply creating a connection to a page that will be used when the user types in a search string.</p>
<p>In the example I&#8217;m pulling from, I&#8217;m searching against a list of facilities for the company.</p>
<pre class="code"><code>facilityProxy = new Ext.data.HttpProxy({url: 'liveQueries/facilities.cfm'});</code></pre>
<p>When the user types in a search string, Ext will then use the <a href="http://extjs.com/deploy/dev/docs/?class=Ext.data.HttpProxy">HTTPProxy</a> to call <em>facilities.cfm</em> with a URL variable named <em>query</em> that contains the search string.  Therefore, if the user typed in &#8216;PHIL&#8217;, the proxy URL would be <strong>liveQueries/facilities.cfm?query=PHIL</strong>.</p>
<p>Now let&#8217;s look at the <em>facilities.cfm</em> code. First, we have to capture the <em>query</em> variable being passed to the page by Ext, which can be done simply with a &lt;cfparam&gt; tag. Then we execute our query.  Once we have the resultset, we&#8217;ll need to serialize it.  I like JSON serialization, so I used the <a href="http://www.epiphantastic.com/cfjson/">CFJSON</a> code from Thomas Messier, Jehiah Czebotar, and others.</p>
<pre class="code"><code>&lt;cfsetting enablecfoutputonly="true"&gt;

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

&lt;cfquery name="facilities" datasource="#datasource_name#"&gt;
select unique facility_no, facility_legal_name
from chg_facility
where (REGEXP_LIKE(facility_no,'#query#','i') OR REGEXP_LIKE(facility_legal_name,'#query#','i'))
order by facility_no asc
&lt;/cfquery&gt;

&lt;cfscript&gt;
jsonBean = createobject("component","webapps.charm.model.ajax.JSON");
jsonEncodedCriteria = jsonBean.encode(data=facilities, queryFormat="array");
writeOutput(jsonEncodedCriteria);
&lt;/cfscript&gt;

&lt;cfsetting enablecfoutputonly="false"&gt;</code></pre>
<p>Ok, so now we&#8217;ve got a JSON-serialized query. What do we do with it?  Well, Ext just happens to have a built-in <a href="http://extjs.com/deploy/dev/docs/?class=Ext.data.JsonReader">JSON reader</a>. Just create a new JsonReader object, tell it what node contains the data (in our case, the node name is <strong>data</strong>) and optionally provide a <strong>totalProperty</strong> argument that contains the total number of records returned.</p>
<p>You then provide a defintion of what a single record of data consist.  You can define a seperate object called a <a href="http://extjs.com/deploy/dev/docs/?class=Ext.data.Record">Record</a>&#8230;.</p>
<pre class="code"><code>facilityRecord = Ext.data.Record.create([
    {name: 'facility_no',         	type: 'string'},
    {name: 'facility_legal_name',	type: 'string'}
]); 

facilityReader = new Ext.data.JsonReader({
    root: 			"data",
    totalProperty:	"recordcount"
}, facilityRecord);</code></pre>
<p>Or just do it inline if the record is simple enough.</p>
<pre class="code"><code>facilityReader = new Ext.data.JsonReader({
    root: 			"data",
    totalProperty:	"recordcount"
}, [
	{name: 'facility_no',         	type: 'string'},
	{name: 'facility_legal_name',	type: 'string'}
]);</code></pre>
<p>Alright, so we&#8217;ve got a proxy object to <em>facilities.cfm</em> that will perform the query on the user&#8217;s search string and return JSON-serialized data.  We&#8217;ve defined the structure of each record, and use a built-in JSON reader to parse the results.</p>
<p>Lastly, we need to populate a data <a href="http://extjs.com/deploy/dev/docs/?class=Ext.data.Store">Store</a> with the deserialized data set that we&#8217;ve retrieved. We simply provide it with the name of the proxy we&#8217;ll be using and which reader it should use to deserialize the data.</p>
<pre class="code"><code>facilityStore = new Ext.data.Store({
    proxy: facilityProxy,
    reader: facilityReader
});</code></pre>
<p>You can also define each element inline instead of creating a separate variables for each object. Here&#8217;s an example:</p>
<pre class="code"><code>new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({url: 'liveQueries/facilities.cfm'}),
    reader: new Ext.data.JsonReader({
        root: 			"data",
        totalProperty:	"recordcount"
    }, [
    	{name: 'facility_no',         	type: 'string'},
    	{name: 'facility_legal_name',	type: 'string'}
	])
})</code></pre>
<p>Now that&#8217;s we&#8217;ve got some interaction code running, let&#8217;s start creating the actual <a href="http://extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox">ComboBox</a>. Create a simple HTML file and place an input element on the page with a unique name.</p>
<pre class="code"><code>&lt;input type="text" size="20" id="facilitySearchField"&gt;</code></pre>
<p>Then, back in your interaction code, let&#8217;s create a <a href="http://extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox">ComboBox</a> instance and tell it to use the data store that we&#8217;ve already defined.</p>
<pre class="code"><code>var search = new Ext.form.ComboBox({
    store: facilityStore,
    minChars:2,
    itemSelector: 'div.search-item',
    tpl: new Ext.XTemplate(
        '&lt;tpl for="."&gt;&lt;div class="search-item"&gt;',
            '{facility_no} - {facility_legal_name}',
        '&lt;/div&gt;&lt;/tpl&gt;'
    ),
    onSelect: function(record){
        // What you want to happen when the enter selects a record (or hit the ENTER key)
    	// Example (redirect to another page):
        //    document.location.href = 'showFacilityDetails.cfm?facilitySelected&amp;fid=' + record.data.facility_no;
    }
});

// Apply the comboBox to the &amp;lt;input&amp;gt; element in our HTML page.
search.applyTo('facilitySearchField');</code></pre>
<h2>Summary</h2>
<h4>HTML Code (example.htm)</h4>
<pre class="code"><code>&lt;html&gt;
&lt;head&gt;
    &lt;link href="css/ext-all.css" rel="stylesheet" type="text/css"&gt;

    &lt;script type="text/javascript" src="js/ext-all.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="js/interaction.example.js"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
    &lt;input type="text" size="20" id="facilitySearchField"&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h4>Javascript Code (interaction.example.js)</h4>
<pre class="code"><code>facilityProxy = new Ext.data.HttpProxy({url: 'liveQueries/facilities.cfm'});

facilityRecord = Ext.data.Record.create([
    {name: 'facility_no',         	type: 'string'},
    {name: 'facility_legal_name',	type: 'string'}
]); 

facilityReader = new Ext.data.JsonReader({
    root: 			"data",
    totalProperty:	"recordcount"
}, facilityRecord);

facilityStore = new Ext.data.Store({
    proxy: facilityProxy,
    reader: facilityReader
});

var search = new Ext.form.ComboBox({
    store: facilityStore,
    minChars:2,
    itemSelector: 'div.search-item',
    tpl: new Ext.XTemplate(
        '&lt;tpl for="."&gt;&lt;div class="search-item"&gt;',
            '{facility_no} - {facility_legal_name}',
        '&lt;/div&gt;&lt;/tpl&gt;'
    ),
    onSelect: function(record){   }
});
search.applyTo('facilitySearchField');</code></pre>
<h4>ColdFusion Code (facilities.cfm)</h4>
<pre class="code"><code>&lt;cfsetting enablecfoutputonly="true"&gt;

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

&lt;cfquery name="facilities" datasource="#datasource_name#"&gt;
    // Perform search based on user's search string (query parameter)
&lt;/cfquery&gt;

&lt;cfscript&gt;
jsonBean = createobject("component","webapps.model.ajax.JSON");
jsonEncodedCriteria = jsonBean.encode(data=facilities, queryFormat="array");
writeOutput(jsonEncodedCriteria);
&lt;/cfscript&gt;

&lt;cfsetting enablecfoutputonly="false"&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fusioncube.net/index.php/ext-simple-autocomplete-example/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

