<?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>Outside the Box() &#187; Programming</title>
	<atom:link href="http://www.sporcic.org/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sporcic.org</link>
	<description>Blog of Tim Sporcic</description>
	<lastBuildDate>Tue, 13 Jul 2010 14:57:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tuning Your ExtJS Theme</title>
		<link>http://www.sporcic.org/2010/07/tuning-extjs-theme/</link>
		<comments>http://www.sporcic.org/2010/07/tuning-extjs-theme/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 18:49:05 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[extjs]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=540</guid>
		<description><![CDATA[ExtJS is my favorite JavaScript favorite. The guys at Sencha have done an excellent job at building the best JavaScript framework for building intranet RIAs. The only flaw of ExtJS is the lack of themes. Although the provided blue and gray themes are very nice, after looking at them for two years you start to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sencha.com/products/js/">ExtJS</a> is my favorite JavaScript favorite. The guys at <a href="http://www.sencha.com">Sencha</a> have done an excellent job at building the best JavaScript framework for building intranet RIAs. The only flaw of ExtJS is the lack of themes. Although the provided blue and gray themes are very nice, after looking at them for two years you start to long for more variety.</p>
<p>There have been some attempts to theme ExtJS.  <a href="http://extthemes.com">Extthemes</a> has built a pretty nice collection of commercial themes, but sometimes all I need is a little bling without the need to completely re-theme the framework. For example, on a recent project, I&#8217;m starting to introduce ExtJS and am making use of the <code>Ext.Panel</code> widget for laying out div elements. </p>
<p>Here&#8217;s what a basic Panel looks like in ExtJS:</p>
<p><img src="http://www.sporcic.org/images/extjs/basic-panel.png" alt="ExtJS default panel" /></p>
<p>And here&#8217;s the code I used to create the panel:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> panel <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Panel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      width<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span>
      height<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span>
      title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Test Panel'</span><span style="color: #339933;">,</span>
      renderTo<span style="color: #339933;">:</span> <span style="color: #3366CC;">'box'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I&#8217;ve got a div specified in the HTML like this <code>&lt;div id="box"&gt;&lt;/div&gt;</code> which is where the Panel is being rendered to. This is very nice if your site&#8217;s look-and-feel is baby blue, but this won&#8217;t cut it if you need a different color scheme. Fortunately, Panels are extremely easy to stylize through some simple CSS overrides.</p>
<p>The first step is to decide what color you need for the Panel&#8217;s header. The default theme uses a gradient image, which looks better than just specifying a background color. Gradients are pretty easy to created in Photoshop, but you can get a very nice gradient that exactly matches your needs by taking advantage of the <a href="http://jqueryui.com/themeroller/">Themeroller</a> tool for <a href="http://jqueryui.com">JQuery UI</a>. Use the Header/Toolbar customization and choose the color and gradient effect you want for the header.</p>
<p>After you have the header just the way you want it, download the whole theme bundle, extract it someplace and copy the image file for the header into your project directory.</p>
<p>There are three CSS selectors you need to override to apply your customization to the Panel. They are <code>.x-panel-header</code>, <code>.xpanel-header-text</code> and <code>.x-panel-body</code>. For my example, I just borrowed the header image for the Eggplant theme and configured these selectors to produce the following:</p>
<p><img src="http://www.sporcic.org/images/extjs/styled-panel.png" alt="ExtJS styled panel" /></p>
<p>Here is what I specified in my CSS file to override the default style:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.x-panel-header</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">resources/images/eggplant.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">center</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.x-panel-body</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fafad2</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.x-panel-header-text</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">14px</span> Consolas<span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> san-<span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>In the <code>.x-panel-header</code> selector, I specified the background to be the header image I got out of the Themeroller theme. For a little added bling, I changed the text alignment to center the text and set the border color to black. Note, I renamed the gradient image from the cryptic name Themeroller created to eggplant.png.</p>
<p>For the <code>.x-panel-body</code> selector, I set the border color to match the one I specified in the selector above. If you don&#8217;t do this, you&#8217;ll still have the default border around the center. I also specify a light-yellow background color for the contents of the Panel.</p>
<p>Finally, for the <code>.x-panel-header-text</code> section, I change the appearance of the font from the default blue text to a white text in a different font.</p>
<p>Now you have a panel which can perfectly match any color scheme you need to support and it gives you a simple way to introduce ExtJS without it standing out from what you are already doing. For example, on my project, I&#8217;m going to use a pair of <code>Ext.Panel</code> widgets on the sidebar for navigation and a most-recently-used files list, which looks something like this:</p>
<p><img src="http://www.sporcic.org/images/extjs/custom-panel.png" alt="ExtJS custom panels" /></p>
<p>In this example, the theme is still blue, but I changed the header gradient, the shade of blue for the lines, and applied a light-gray background. </p>
<h3>Some Tips</h3>
<ol>
<li>Firebug or Webkit (Chrome/Safari) are your friends. Use the element inspectors to look at what classes are applied to the various ExtJS widgets. Theming ExtJS is all about overriding the existing styles.</li>
<li>Panels are about the easiest thing to style, and it gets harder from there. If you really want to get a custom theme, I suggest start by working with the <code>x-theme-gray.css</code> and then overriding from there. The gray theme will give you widgets that blend pretty easily with any theme, and then you can selectively add some bling to the elements you care about.</li>
<li>Remember that your overridden styles must come <i>after</i> the stylesheet link for ExtJS. For example, if your stylesheet with the overridden styles is called <code>custom.css</code>, ensure your header section contains this:

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;extjs/resources/css/ext-all.css&quot;/&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;extjs/resources/css/xtheme-gray.css&quot;/&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;stylesheets/custom.css&quot;/&gt;</pre></div></div>

</li>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2010/07/tuning-extjs-theme/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Revenge of the Browser</title>
		<link>http://www.sporcic.org/2010/06/revenge-of-the-browser/</link>
		<comments>http://www.sporcic.org/2010/06/revenge-of-the-browser/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 13:02:14 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=512</guid>
		<description><![CDATA[Last weekend I attended the awesome Texas Javascript conference down in Austin, TX. This was probably the best geek conference I&#8217;ve been too. It made the early Rails conference look downright corporate. TXJS had awesome parties sponsored by Google and Facebook, the top names in JavaScript for speakers, and an open bar with mimosas for [...]]]></description>
			<content:encoded><![CDATA[<p>Last weekend I attended the awesome <a href="http://texasjavascript.com/">Texas Javascript</a> conference down in Austin, TX. This was probably the best geek conference I&#8217;ve been too. It made the early Rails conference look downright corporate. TXJS had awesome parties sponsored by Google and Facebook, the top names in JavaScript for speakers, and an open bar with mimosas for breakfast. This sets the bar pretty high on the geek awesomeness scale.</p>
<p>One of the most interesting discussions at the conference revolved around server-side JavaScript. Some very clever programmers have taken the V8 JavaScript runtime from Chrome, wrapped it with a library and pushed it out as a runtime for executing JS scripts on the server. The project is called <a href="http://nodejs.org">NodeJS</a> and it already has a pretty rich <a href="http://wiki.github.com/ry/node/modules">plugin environment</a> around it. The implication is you can actually write a high-performance server-side application in JavaScript.</p>
<p>The trend for the past several years has been for the server-side programming languages to hide the JavaScript from developers. Both Rails and GWT approach things with a &#8220;use our language to do it all&#8221;. There is obviously value in this approach for people who don&#8217;t know JavaScript, but NodeJS suddenly flips that model on its ear. </p>
<p>The NodeJS story is &#8220;you use JavaScript already in the browser, so why not use the same skills on the server&#8221;. We now have a programming paradigm established at the browser that is pushing in to the lower tiers, rather than the lower tiers pushing out to the web. NodeJS has potential to obsolete a lot of what we think of as server-side development. Both Yahoo and ExtJS have projects in the works that use NodeJS as the backend, and I bet Google must have something going too.</p>
<p>NodeJS is basically the new Ruby. Keep an eye on what the cool kids start doing with it, and give it a try yourself. We&#8217;ll be seeing a lot more of it in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2010/06/revenge-of-the-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Case for Strength</title>
		<link>http://www.sporcic.org/2010/05/the-case-for-strength/</link>
		<comments>http://www.sporcic.org/2010/05/the-case-for-strength/#comments</comments>
		<pubDate>Sat, 22 May 2010 13:53:47 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=495</guid>
		<description><![CDATA[The pendulum has swung once again and I have escaped the world of architecture to get back to delivering software. I left Bank of America (Countrywide) for the second time last week, but not the mortgage industry. I am now the Application Manager for the origination system Nationstar Mortgage.
The challenge for my first week has [...]]]></description>
			<content:encoded><![CDATA[<p>The pendulum has swung once again and I have escaped the world of architecture to get back to delivering software. I left Bank of America (Countrywide) for the second time last week, but not the mortgage industry. I am now the Application Manager for the origination system <a href="https://www.nationstarmtg.com">Nationstar Mortgage</a>.</p>
<p>The challenge for my first week has been getting my head around the codebase. The application is a combination of a vendor solution along with a lot of custom code built up along the side. Like a lot of in house applications which started small, this one has grown in to what I call the &#8220;big ball of mud&#8221; pattern, where there was not the long term vision and architectural rigor for structuring a scalable, maintainable application. The fun part is it is my  job to fix it.</p>
<p>After a week of looking at code, I have acquired new-found love for strong typing. In a mad genius, army-of-one development mode, the freedom of dynamic languages is both liberating and powerful. But as you start to add more cooks to the kitchen, things start to go downhill rapidly. </p>
<p>Case in point, I was attempted to troubleshoot a sporadic NullPointerException that pops-up in production. The culprit method is getting an object out of a list, and calling a method on a nested object it contains. I&#8217;m trying to determine if the object itself is null, or if the nested object is missing, so I&#8217;m tracing back how to where that object comes from.</p>
<p>The problem is that the instance of the object comes from an ArrayList, which is created from an object in HashMap, and neither makes use of generics. I know what my final object is supposed to be, but I have to trace back through other code to see how that the HashMap is being populated with.</p>
<p>This whole codebase has left me begging for generics. Generics in Java are not just about type safety, they are about documenting your code. For example, instead of:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">ArrayList</span> myLoans <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">HashMap</span> properties <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You should make use of generics so that other people aren&#8217;t left guessing on the contents:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;">List<span style="color: #339933;">&lt;</span>Loan<span style="color: #339933;">&gt;</span> myLoans = <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Loan<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Map<span style="color: #339933;">&lt;</span>String,Address<span style="color: #339933;">&gt;</span> properties  = <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String,Address<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the second case, I know I have a list of Loan objects, and I know I have a map where the key is a String and the entry is an Address object. I don&#8217;t have to jump around in the code to see how they are used to understand exactly what they contain. Note another difference: I use the collection interfaces (List, Map) in my declaration rather than the implementation classes (ArrayList, HashMap). </p>
<p>From an object-oriented programming perspective, you should always strive to hide the implementation details of objects. And by using the interface, you buy yourself the flexibility of being able to swap out for a new implementation class without breaking the code. For example you could change the ArrayList to a Vector if you needed the synchronization and not break downstream code.</p>
<p>So with my dive back in to the bowels of enterprise software development, I&#8217;ve regained a new appreciation for my old friend Java. There is great strength in strong typing which permits you to build much more maintainable applications than the alternatives. Use that strength and make your team happy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2010/05/the-case-for-strength/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;ll Buy That!</title>
		<link>http://www.sporcic.org/2010/02/ill-buy-that/</link>
		<comments>http://www.sporcic.org/2010/02/ill-buy-that/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 01:42:47 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ipad]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=483</guid>
		<description><![CDATA[So it has been a few weeks since Apple announced the iPad. I was pretty excited when I saw it, but gave it some time to digest what everyone else was saying and also the implications. The iPad definitely has its detractors, with most somehow working a feminine hygiene joke into their rants. But in [...]]]></description>
			<content:encoded><![CDATA[<p>So it has been a few weeks since Apple announced the <a href="http://www.apple.com/ipad/">iPad</a>. I was pretty excited when I saw it, but gave it some time to digest what everyone else was saying and also the implications. The iPad definitely has its <a href="http://www.infoworld.com/d/windows/why-apples-rumored-itablet-will-fail-big-time-119?source=rs">detractors</a>, with most somehow working a feminine hygiene joke into their rants. But in the end, I&#8217;ll happily be first in line to buy one. Why?</p>
<p>The game changing aspect of the iPad is Safari. There will be plenty of cutesy apps, but I would sooner chew my own arm off than work with Objective-C. It is a disgusting abomination of a language. But having Safari on the iPad means developing feature-rich RIAs in HTML 5, with fast JavaScript, that can be packaged to deploy so that they appear the same as other iPad/iPhone applications (Dock icons, etc&#8230;). Best yet, Apple is giving the finger to Adobe and Flash. The iPad is going to put a nail in the coffin of Flash and help advance web standards by leaps and bounds.</p>
<p>Yehuda Katz of the jQuery team summarized it best in this <a href="http://yehudakatz.com/2010/01/27/the-irony-of-the-ipad-a-great-day-for-open-technologies/">blog post</a>. I completely agree with him. The iPad is a godsend for HTML and JavaScript developers and anyone who values open web standards should be doing back flips right now. A thin tablet device with a cutting edge browser and wireless networking is going to open up a world of vertical market possibilities for web developers. I was really impressed with what Graham Glass did with his iPhone web application for <a href="http://grahamglass.blogs.com/main/2010/01/edu-20-for-iphone-update.html">EDU 2.0</a>, and can only imagine how an application like this could take advantage of the iPad.</p>
<p>Check out the <a href="http://developer.apple.com/safari/library/navigation/index.html">Safari Developer Documentation</a> on Apple&#8217;s site sometime to really understand the vast programming playground Apple is creating for us. I&#8217;m actually excited about web development for the iPad and am looking forward to getting mine to play with. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2010/02/ill-buy-that/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Flashback</title>
		<link>http://www.sporcic.org/2010/01/rails-flashback/</link>
		<comments>http://www.sporcic.org/2010/01/rails-flashback/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 03:45:57 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=478</guid>
		<description><![CDATA[While poking around one of the Ruby on Rails sites, I stumbled upon the video of DHH&#8217;s keynote at RailsConf 2009. Rails 3 looks really cool, but DHH has definitely mellowed from the 2006 and 2007 RailsConfs I attended. Just watching the keynote brought back some good memories of the 2007 RailsConf.
RailsConf 2007 was held [...]]]></description>
			<content:encoded><![CDATA[<p>While poking around one of the <a href="http://rubyonrails.org/">Ruby on Rails</a> sites, I stumbled upon the video of <a href="http://railsconf.blip.tv/file/2081411/">DHH&#8217;s keynote</a> at <a href="http://en.oreilly.com/rails2009">RailsConf 2009</a>. Rails 3 looks really cool, but DHH has definitely mellowed from the 2006 and 2007 RailsConfs I attended. Just watching the keynote brought back some good memories of the 2007 RailsConf.</p>
<p>RailsConf 2007 was held in Portland, Oregon, which is about the most awesome city I&#8217;ve been to for a conference. It has all the amenities of a big city, but still keeps a quirky small town feel. Between the conference, awesome micro-brews, and <a href="http://www.powells.com/">Powell Books</a>, it was a really good time.</p>
<p>This was the RailsConf I went to with my Windows notebook while 99% of everyone there was running on a MacBook, so I played the leper. The speakers were great, and it was absolutely hilarious when one of the vendors had the <a href="http://www.extra-action.com/">Extra Action Marching Band</a> show up at lunch the first day to perform. It pissed off the stodgy convention center management, but it was a sight to see. Check out James Duncan Davidson&#8217;s <a href="http://www.flickr.com/photos/x180/sets/72157600225783815/">excellent photos</a> if you want to see how fun a RailsConf could be. </p>
<p>I was thinking of going to RailsConf this year, but it is in Baltimore. I&#8217;ve never been a fan of east coast conferences, and I&#8217;m worried RailsConf is losing its fire. Just like JavaOne tapered off in to boredom, RailsConf on the east coast could be its jump the shark moment. But if they ever get around to having it in Portland again, I&#8217;ll be there. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2010/01/rails-flashback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cool CBT</title>
		<link>http://www.sporcic.org/2010/01/cool-cbt/</link>
		<comments>http://www.sporcic.org/2010/01/cool-cbt/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 03:21:37 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[innerworkings]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=473</guid>
		<description><![CDATA[After enough time in technology, one tends to become pretty jaded about vendor claims. I&#8217;ve seen enough miracle solutions before, most them involving code generation to &#8220;eliminate the developer.&#8221; It has gotten to the point that if I even hear a vendor mention SOA, I whip out a can of Bear Mace and let them [...]]]></description>
			<content:encoded><![CDATA[<p>After enough time in technology, one tends to become pretty jaded about vendor claims. I&#8217;ve seen enough miracle solutions before, most them involving code generation to &#8220;eliminate the developer.&#8221; It has gotten to the point that if I even hear a vendor mention SOA, I whip out a can of <a href="http://www.mace.com/index.php/personal_defense/sporting-outdoor/animal-repellants/mace-bear-pepper-spray.html">Bear Mace</a> and let them have it.</p>
<p>So it came as a great personal surprise when I actually saw a vendor demo for something both cool and practical. I sit on the .NET Center of Excellence for our oversized company, and part of the role is listening to vendors show off their latest and greatest. Our last demo was from a company called <a href="http://www.innerworkings.com/solutions/developer">InnerWorkings</a> and I had honestly never heard of them before the demo.</p>
<p>InnerWorkings has an incredibly awesome computer-based training (CBT) system for learning .NET. It goes beyond book reading and is heavily based around coding exercises which are even scored by the system. It has a Visual Studio plugin for working with the vast library of learning material and links to O&#8217;Reilly&#8217;s <a href="http://my.safaribooksonline.com">Safari Books</a> for reference.</p>
<p>I had never seen a CBT product before this which I would actually considered to be effective. This looked good enough that I would almost be willing to invest my own dollars. If you need to bring a development team up to speed on .NET programming, or a specific area on the bleeding edge, I highly recommend taking a look at InnerWorkings. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2010/01/cool-cbt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(Ext.)Direct Miss</title>
		<link>http://www.sporcic.org/2009/05/extdirect-miss/</link>
		<comments>http://www.sporcic.org/2009/05/extdirect-miss/#comments</comments>
		<pubDate>Sun, 17 May 2009 16:19:40 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[extjs]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=375</guid>
		<description><![CDATA[One of the biggest announcements from last month&#8217;s ExtJS Conference was the new Ext.Direct functionality in ExtJS 3.0. My criticism at the time was that there was a lot of smoke, but no fire. Almost every session mentioned it in some way or another, but they weren&#8217;t producing any enterprise-worthy server code showing how it [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest announcements from last month&#8217;s <a href="http://www.extjs.com/conference/">ExtJS Conference</a> was the new Ext.Direct functionality in ExtJS 3.0. My criticism at the time was that there was a lot of smoke, but no fire. Almost every session mentioned it in some way or another, but they weren&#8217;t producing any enterprise-worthy server code showing how it is implemented.</p>
<p>Now, a month later, more details are starting to emerge, including implementations for various technologies. I sat down yesterday morning intending to take a look at the server side code in the <a href="http://extjs.com/forum/showthread.php?t=67992">Ext.Direct Pack</a>; in particular the .NET and Java implementations. I was pretty disappointed with what I saw.</p>
<p>To understand my disappointment, you need to understand a bit of history around what Ext.Direct is attempting to do. Ext.Direct is going to be an RPC layer that exposes stub objects on the client JavaScript side that remotes the method calls to the server using JSON (or POST parameters). The protocol definition is designed to be technology-agnostic and easy to implement. In implementation, it would be the near-equivalent of <a href="http://directwebremoting.org/">DWR</a>, except it would also run on PHP, C#, Ruby, etc&#8230;</p>
<p>Since I&#8217;m familiar with CORBA, RMI, SOAP and WCF, I approached Ext.Direct with a more critical eye. The biggest glaring hole in Ext.Direct is the parameter passing. Let&#8217;s take a look at a couple examples to demonstrate the problem. All the examples will assume a Java backend, and the service we&#8217;ll expose is the PersonService. I&#8217;ll work from the interface, since we don&#8217;t care about the implementation details:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> PersonService <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Easy</h3>
<p>We&#8217;ll add a method to PersonService to demonstrate the simplest scenario:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">int</span> getPersonCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The payload from Ext.Direct would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;action&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;PersonService&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;getPersonCount&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;rpc&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;tid&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is the absolute easiest method to deal with. The operation takes no parameters, and the return value is a primitive. Ext.Direct can deal with this easily, but so could any AJAX library, so no secret sauce here.</p>
<h3>Object</h3>
<p>One of the key advantages to an RPC protocol is the ability to pass Objects. Well complicate things a bit by adding the following method to the PersonService:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> Person getPerson<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>For our example, we&#8217;ll assume the Person class looks like this. I&#8217;m not including setters/getters to try and keep it short:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Person <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">int</span> id<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">String</span> name<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">int</span> age<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399; font-weight: bold;">Date</span> birthDate<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the method I added above, the JSON payload from Ext.Direct stays pretty simple:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;action&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;PersonService&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;getPerson&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;rpc&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;tid&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>This should return the Person with the ID of 1, and depends on the server code to correctly serialize the Person object to JSON.</p>
<h3>Harder</h3>
<p>Now let&#8217;s make things painful. I&#8217;m going to include a method to add a Person.</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> addPerson<span style="color: #009900;">&#40;</span>Person person<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is where the wheels fly off of Ext.Direct. Since the protocol specifies the data element as an array, I&#8217;m not clear on how Ext.Direct would deal with this from the client side. Every example so far works with primitives as parameters, so I haven&#8217;t determined what it would do with a Person. </p>
<p>Ext.Direct would be much happier if I defined the addPerson method like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> addPerson<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> id, <span style="color: #003399; font-weight: bold;">String</span> name,<span style="color: #006600; font-weight: bold;">int</span> age, <span style="color: #003399; font-weight: bold;">Date</span> birthdate<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Then, the JSON payload would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;action&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;PersonService&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;addPerson&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;John Doe&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">25</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Sun May 01 1985 00:00:00 GMT-0500 (Central Daylight Time)&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;rpc&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;tid&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>Even in this &#8220;happy path&#8221; scenario for dealing with an object, your server-side implementation would need to be able to correctly deserialize the stringified javascript date object, which is not anything the current implementations handle.</p>
<p>The <a href="http://extjs.com/products/extjs/direct.php">protocol specification</a> states that the data element can also be a JSON object with named parameters, but it is not supported in the first implementation. This is going to be absolutely critical if Ext.Direct is going to evolve into a real RPC protocol. For example, using a JSON object for the data element in the above example would result in a JSON payload like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;action&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;PersonService&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;method&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;addPerson&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>
           <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;John Doe&quot;</span><span style="color: #339933;">,</span> 
           age<span style="color: #339933;">:</span> <span style="color: #CC0000;">25</span><span style="color: #339933;">,</span> 
           birthdate<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Sun May 01 1985 00:00:00 GMT-0500 (Central Daylight Time)&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;rpc&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #3366CC;">&quot;tid&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>This would at least allow the server code a means to try and instantiate an instance of the Person object, as long as the server code is implemented in a language that allows for reflection of the Object.</p>
<p>My grief with Ext.Direct is that correctly implementing the server-side code to support the specification is a non-trivial endeavor. One big piece missing is the metadata. In other RPC mechanisms, there is strongly-typed metadata which can be used to create the stubs. For example, CORBA has IDL and SOAP has WSDL. </p>
<p>Ext.Direct is missing a metadata layer to facilitate the passing of Object values. It is going to be difficult to implement a complete server-side stack to handle the permutations that will arise. Developers will either need to dumb-down the exposed services to handle the limitations of Ext.Direct, or else they will end up doing a lot of custom work on top of the server side implementation to handle the type coercion.</p>
<p>I&#8217;m still not convinced Ext.Direct is the right path for ExtJS to be barking down. There are already established, tested protocols for handling RPC via JavaScript (DRW, WCF), and ExtJS already works quite well with basic AJAX over the HTTP protocol. Ext.Direct is adding a level of complexity to ExtJS which could easily turn into a rabbit hole that sucks up all their time. I would prefer they focus their precious development hours on the client library and leave the communication layers decisions to us. RPC is a complicated problem with a lot of history around it, and there is no reason for them to try and invent a new wheel in this space.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2009/05/extdirect-miss/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flexible Spring</title>
		<link>http://www.sporcic.org/2009/05/flexible-spring/</link>
		<comments>http://www.sporcic.org/2009/05/flexible-spring/#comments</comments>
		<pubDate>Sun, 10 May 2009 01:38:50 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=359</guid>
		<description><![CDATA[As I mentioned in my prior post, I&#8217;ve been going through the great Flex in a Week from Adobe. I finally hit Day 3 and had a need to play with BlazeDS for the second lesson. Being a fan of the Spring Framework, I decided to use the recently released Spring Blaze DS Integration 1.0rc1 [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my prior post, I&#8217;ve been going through the great <a href="http://www.adobe.com/devnet/flex/videotraining/">Flex in a Week</a> from Adobe. I finally hit Day 3 and had a need to play with BlazeDS for the second lesson. Being a fan of the <a href="http://www.springframework.org">Spring Framework</a>, I decided to use the recently released <a href="http://www.springsource.org/spring-flex">Spring Blaze DS Integration 1.0rc1</a> (Spring-Flex). This ended up turning in to a bigger beatdown than I expected, for several reasons.</p>
<p>I really wanted to use the Spring-Flex integration because I like the annotation-driven dependency injection option that Spring brings to the table. Unfortunately, I could not find a single comprehensive document or example showing how to setup a project from end-to-end using Flex and Spring-Flex. I started with my Spring template project, adding in the BlazeDS dependencies and configuration. I then stripped out the stuff I didn&#8217;t care about for this example. Then I went digging through the various reference guides and blog posts trying to figure out the correct configuration I needed on both the Java and Flex side.</p>
<p>After about three days of hair pulling, the pieces finally started to fall in to place. Once I understood the configuration, it became a breeze to configure services to be exposed by Spring-Flex and to call those services from Flex via a <code>RemoteObject</code>. I&#8217;ve linked the complete Java project and Flex project archive below:</p>
<p><a href="http://www.sporcic.org/data/EmployeeManager-Java.zip">Spring-Flex Project</a></p>
<p><a href="http://www.sporcic.org/data/EmployeeManagement-Flex.zip">Flexbuilder Project Archive</a></p>
<p>There is a README.txt file in the root of the Java project directory that walks through the setup. This project is configured to talk to a MySQL database using an iBatis DAO layer and includes the setup scripts, all run from Ant. The build file also makes use of Ivy to grab dependencies, thus reducing the number of jars I have to include.</p>
<p>The Flex project is configured to talk to the exposed employeeService on localhost, so you&#8217;ll need to change the configuration of the <code>RemoteObject</code> if you want to point to a different destination.</p>
<p>Here are some of my lessons learned that will hopefully help others:</p>
<p><b>#1</b>: Life is easier if you keep BlazeDS&#8217;s <code>services-config.xml</code> file in the default location: <code>WEB-INF/flex/services-config.xml</code>. The version of this file that comes with the BlazeDS turnkey download has a small problem. It does not specify default channels, which is what FlexBuilder will use to figure out what is going on. Look at the version I have in the Java file and notice at the top:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;services<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default-channels<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;channel</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;my-amf&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default-channels<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/services<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>You&#8217;ll want this in your services-config.xml file if you plan on specifying an application server in FlexBuilder.</p>
<p><b>#2</b>: And on the subject of application servers, you actually don&#8217;t even need to specify the server technology. I built my solution as a standalone Flex project with a standalone Java project and had the two talking together without a problem.</p>
<p>The secret to making it work is in how you configure the <code>RemoteObject</code> in FlexBuilder. Here is the configuration for my <code>RemoteObject</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:RemoteObject</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;employeeRO&quot;</span> </span>
<span style="color: #009900;">  <span style="color: #000066;">destination</span>=<span style="color: #ff0000;">&quot;employeeService&quot;</span> </span>
<span style="color: #009900;">  <span style="color: #000066;">showBusyCursor</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">fault</span>=<span style="color: #ff0000;">&quot;handleFault(event)&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:channelSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:ChannelSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:AMFChannel</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;amf&quot;</span> <span style="color: #000066;">uri</span>=<span style="color: #ff0000;">&quot;http://localhost:8080/flex/messagebroker/amf&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:ChannelSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:channelSet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;getEmployees&quot;</span> <span style="color: #000066;">result</span>=<span style="color: #ff0000;">&quot;allEmployeesHandler(event)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;doCreate&quot;</span> <span style="color: #000066;">result</span>=<span style="color: #ff0000;">&quot;employeeHandler(event)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;doUpdate&quot;</span> <span style="color: #000066;">result</span>=<span style="color: #ff0000;">&quot;employeeHandler(event)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:method</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;doDelete&quot;</span> <span style="color: #000066;">result</span>=<span style="color: #ff0000;">&quot;employeeDeleteHandler(event)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:RemoteObject<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Specifying the <code>ChannelSet</code> enables you to take control of where the <code>RemoteObject</code> is binding to instead of relying of FlexBuilder magic. Just change the URI to point to the correct location.</p>
<p>There is one little catch. You need to set the FlexBuilder build output directory to Tomcat&#8217;s webapps/flex directory (after you have deployed the war file), or you&#8217;ll get a security exception about breaking out of the sandbox. I&#8217;m guessing that the flex file is looking for the services-config.xml file to figure out what it is supposed to do, and if it is not in the correct directory relative to the SWF file, your application will barf. So deploy the flex.war file from the Java project first, then play with the flex half of it.</p>
<p><b>#3</b>: Once you have the dependencies sorted out, configuring the Flex broker is literally a one-line configuration option. Check out <code>web/WEB-INF/flexDispatch-servlet.xml</code> in the Java project and notice this line:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;flex:message-broker</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>That&#8217;s all you need. Really. This one line of config uses &#8220;sensible defaults&#8221; to initialize BlazeDS. It will read <code>services-config.xml</code> from the default location (see tip #1) and setup the endpoints for you based on the configuration. </p>
<p><b>#4</b>: I&#8217;m a fan of annotation-driven configuration for Spring, and Spring-Flex does not disappoint. Here is the implementation of the <code>EmployeeService</code> class:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;">@Service<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;employeeService&quot;</span><span style="color: #009900;">&#41;</span>
@RemotingDestination
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EmployeeServiceImpl <span style="color: #000000; font-weight: bold;">implements</span> EmployeeService <span style="color: #009900;">&#123;</span>
&nbsp;
    @Autowired
    <span style="color: #000000; font-weight: bold;">private</span> EmployeeDao employeeDao<span style="color: #339933;">;</span>
&nbsp;
    @RemotingInclude
    <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Employee<span style="color: #339933;">&gt;</span> getEmployees<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> employeeDao.<span style="color: #006633;">getEmployees</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RemotingInclude
    <span style="color: #000000; font-weight: bold;">public</span> Employee getEmployee<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> employeeDao.<span style="color: #006633;">getEmployee</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RemotingInclude
    <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Employee<span style="color: #339933;">&gt;</span> getEmployeesByDepartment<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> department<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> employeeDao.<span style="color: #006633;">getEmployeesByDepartment</span><span style="color: #009900;">&#40;</span>department<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RemotingInclude
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> doCreate<span style="color: #009900;">&#40;</span>Employee employee<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        employeeDao.<span style="color: #006633;">createEmployee</span><span style="color: #009900;">&#40;</span>employee<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RemotingInclude
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> doUpdate<span style="color: #009900;">&#40;</span>Employee employee<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        employeeDao.<span style="color: #006633;">updateEmployee</span><span style="color: #009900;">&#40;</span>employee<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @RemotingInclude
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> doDelete<span style="color: #009900;">&#40;</span>Employee employee<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        employeeDao.<span style="color: #006633;">deleteEmployee</span><span style="color: #009900;">&#40;</span> employee.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The top <code>@RemotingDestination</code> tells Spring-Flex this is a service that is going to be exposed via BlazeDS. You can provide an optional parameter specifying which channels to use, if you have several configured. Then, each method you want to expose is annotated with the <code>@RemotingInclude</code> annotation. Methods that should not be exposed can be annotated with the <code>@RemotingExclude</code> annotation.</p>
<p>So if you&#8217;re following along with Flex in a Week, or have just been trying to get Spring-Flex up and talking to a Flex application, give the demo a try and look over the source code. This corresponds to the second video of Flex in a Week, Day 3. I wish I would have known some of these things starting out, so hopefully I can save other people some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2009/05/flexible-spring/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex in a Week</title>
		<link>http://www.sporcic.org/2009/05/flex-in-a-week/</link>
		<comments>http://www.sporcic.org/2009/05/flex-in-a-week/#comments</comments>
		<pubDate>Tue, 05 May 2009 17:35:14 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=348</guid>
		<description><![CDATA[One of my unexpected take-aways from the ExtJS conference last month was that I need to start looking at Flex again. This isn&#8217;t necessarily for the Flex framework itself, but because of AIR. I&#8217;ve started to see a lot more AIR applications popping up, and my Twitter client (Twhirl) is even AIR based. ExtJS with [...]]]></description>
			<content:encoded><![CDATA[<p>One of my unexpected take-aways from the ExtJS conference last month was that I need to start looking at Flex again. This isn&#8217;t necessarily for the Flex framework itself, but because of AIR. I&#8217;ve started to see a lot more AIR applications popping up, and my Twitter client (<a href="http://www.twhirl.org/">Twhirl</a>) is even AIR based. ExtJS with AIR makes for an extremely powerful combination.</p>
<p>So to build a foundation for AIR, I decided to learn Flex. After a strong year of JavaScript, Flex starts to make a lot more sense from a syntax standpoint. And ironically, the best way I&#8217;ve found to learn Flex is free:  <a href="http://www.adobe.com/devnet/flex/videotraining/">Flex in a Week</a>.</p>
<p>Adobe has produced a truly outstanding series of video training classes for Flex. Although it is structured as five days worth of materials, I&#8217;m only getting through half a course each day due to quiet time constraints with a two-year old in the house. I have been very impressed with the quality and level of detail. The videos aren&#8217;t full of fluff and get quickly to code. There are exercises interspersed with the training videos, but I&#8217;ve passed over them, opting instead to follow along with the videos.</p>
<p>The only downfall to my choice to follow the videos instead of the exercises is that Adobe didn&#8217;t make it easy to find some of the supporting pieces you need to follow the videos. For example, there is an XML data file called employees.xml used for a lot of the code in the videos that is nowhere to be found. Ultimately, I found a CSV version of the data file in an <a href="http://www.adobe.com/devnet/air/flex/samples.html#adobe_samples">AIR Sample</a>, along with the images used for building the employee directory application. </p>
<p>In the interest of helping out others who start on Flex in a Week, here are the supporting files necessary for following along with the code. I&#8217;ve only finished the second day, so I&#8217;ll try and add any additional parts I find missing.</p>
<ul>
<li><a href="http://www.sporcic.org/data/employees.xml">employees.xml</a> &#8211; the XML data file with the employee information (right-click to save it)</li>
<li><a href='http://www.sporcic.org/wp-content/uploads/2009/05/flexinaweek-images.zip'>headshot images</a> &#8211; the thumbnail images for the directory, both normal and small sized</li>
</ul>
<p>I&#8217;m hoping to finish up the tutorial this week and jump into more complex things with Flex. I&#8217;ve been very impressed so far, although not enough to eat crow yet on my negativity towards Flash in general. </p>
<p>What about Flex books? I picked up <a href="http://www.amazon.com/gp/product/0596516215?ie=UTF8&#038;tag=outhbo-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596516215">Programming Flex 3: The Comprehensive Guide to Creating Rich Internet Applications with Adobe Flex</a><img src="http://www.assoc-amazon.com/e/ir?t=outhbo-20&#038;l=as2&#038;o=1&#038;a=0596516215" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> and it has been a total disappointment. The book is very poorly structured and it jumps all over the place without a coherent plan. It swings between excessive detail of the Flash engine, followed by trivial, poorly explained examples of the Flex widgets. I may find value in it later as a reference, but am dumping it for now.</p>
<p>I did pick up another book that I really like a lot: <a href="http://www.amazon.com/gp/product/0596517327?ie=UTF8&#038;tag=outhbo-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596517327">Learning Flex 3: Getting up to Speed with Rich Internet Applications (Adobe Developer Library)</a><img src="http://www.assoc-amazon.com/e/ir?t=outhbo-20&#038;l=as2&#038;o=1&#038;a=0596517327" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. This one is well structured and gets to the things I&#8217;m interested in, not the nitty-gritty details of the Flash player. I would recommend this one for anyone who is at a similar point in their Flex learning experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2009/05/flex-in-a-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beyond the Core</title>
		<link>http://www.sporcic.org/2009/04/beyond-the-core/</link>
		<comments>http://www.sporcic.org/2009/04/beyond-the-core/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 02:13:18 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[extcore]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.sporcic.org/?p=260</guid>
		<description><![CDATA[In my earlier post, I compared the new Ext Core JavaScript library with JQuery to demonstrate how close they are on core functionality. I explicitly kept the scope narrowed down to areas where the two libraries overlapped, and my conclusion was that both are winners but I prefer Ext Core since I use ExtJS and [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://www.sporcic.org/2009/04/ext-core/">earlier post</a>, I compared the new <a href="http://extjs.com/products/extcore/">Ext Core</a> JavaScript library with <a href="http://jquery.com/">JQuery</a> to demonstrate how close they are on core functionality. I explicitly kept the scope narrowed down to areas where the two libraries overlapped, and my conclusion was that both are winners but I prefer Ext Core since I use <a href="http://extjs.com/products/extjs/">ExtJS</a> and prefer the coding style. </p>
<p>In this post, I want to get in to demonstrating some of the features of Ext Core that are either coded differently from JQuery or that the base JQuery library does not implement. The excellent Ext.Core <a href="http://extjs.com/products/extcore/manual/">manual</a> has more detail on all the functions, so I&#8217;ll just bring attention to some of cool functionality I like. </p>
<h3>Base Class Enhancements</h3>
<p>One feature that might be controversial for some developers is that Ext Core augments some of the base JavaScript objects to ensure some features are present across implementations and to add some useful helper methods. The JavaScript Augmentation section of the manual has details on all the enhanced methods. Function, Array and String are the three base objects that get augmented.</p>
<p>For example, the String object is augmented with a static <code>format()</code> method that essentially allows the String to function like a typical printf function:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> dest <span style="color: #339933;">=</span> <span style="color: #3366CC;">'World'</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> greeting <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Hello'</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> msg <span style="color: #339933;">=</span> String.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'{0}, {1}!'</span><span style="color: #339933;">,</span>greeting<span style="color: #339933;">,</span> dest<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// msg contains &quot;Hello, World!&quot;</span></pre></div></div>

<p>The Array object is augmented with <code>indexOf()</code> and <code>remove()</code> methods, and the Function object itself picks up several OO-centric functions. </p>
<p>The reasoning behind the augmentations are in the manual. I have mixed feelings on augmenting the language&#8217;s base objects, but the features are appreciated.</p>
<h3>Namespaces</h3>
<p>Using a namespace mechanism so that all your variables don&#8217;t pollute the global namespace is something every JavaScript coder should be doing. There are plenty of code snippets out there to demonstrate how this is done, but Ext Core makes it easy for you by including namespace support as a part of the library. All this is handled through the <code>Ext.namespace()</code> static method.</p>
<p>Take a look at the sample below. The comments indicate the filenames:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// first.js</span>
Ext.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'First'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
First.<span style="color: #000066;">name</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Tim'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// second.js</span>
Ext.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Second.<span style="color: #660066;">sayHello</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> String.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello, {0}'</span><span style="color: #339933;">,</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// main.js</span>
Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Second.<span style="color: #660066;">sayHello</span><span style="color: #009900;">&#40;</span> First.<span style="color: #000066;">name</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The three JavaScript files don&#8217;t even need to be imported in this order. Everything happens through the namespace references declared at the tops of the files and managed by Ext Core. In this case, objects called First and Second were created under window, and the sayHello method and &#8216;name&#8217; variable were placed under them. This means our code only added two variables to the global space. This didn&#8217;t make a difference with only two variable declarations, but can have a huge impact with a typical application.</p>
<p>Namespaces can be hierarchical, so you can limit the global pollution to a single entry. For example, you can define a namespace like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Application.Init'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ext Core will create all the intermediate namespaces, so you could places variables under both <code>Application.Init</code> and <code>Application</code> with this single declaration. This provides a similar naming hierarchy to what you would find in Java packages or C# namespaces.</p>
<h3>Encode and Decode</h3>
<p>Ext Core provides helper methods to encode and decode both JSON and URL-encoded data. The <code>Ext.encode</code> and <code>Ext.decode</code> will encode or decode JSON objects to and from Strings. This is useful for the AJAX methods, as I demonstrated in my other post. In the current beta, the encode and decode methods aren&#8217;t implemented yet, but they are in the documentation, so I&#8217;m expecting to see them before the final release.</p>
<p>The <code>Ext.urlEncode</code> and <code>Ext.urlDecode</code> methods will encode or decode JSON objects to URL-encoded strings. One typical example is to decode query string parameters. For example, if the page URL was this: <code>http://mycoolapp.com?name=Tim&#038;lang=Java</code>, you could easily decode the query string into a JSON object using this snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> params <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">decode</span><span style="color: #009900;">&#40;</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">search</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> String.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello, {0}'</span><span style="color: #339933;">,</span> params.<span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Yes, this is a bit of a hack. I didn&#8217;t do error checking to ensure there was a value for search before using substr(). The substr() is necessary when working with a query string because the search value will start with a question mark (?), which the <code>Ext.urlDecode</code> method won&#8217;t strip off. </p>
<h3>Templates</h3>
<p>Ext Core thankfully includes Templates, a feature generously carried down from ExtJS. Templates simplify the repetitive generation of HTML fragments, which is something that typically happens in AJAX intensive web application. The Ext.Template class allows you to define an HTML fragment as a template, using tokens which will be replaced with the values from a JSON object. For example, here is a code sample of a Template used to format an RSS feed from Slashdot that I turned into a JSON object:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Feed.data is an array of JSON objects that look like this:</span>
<span style="color: #006600; font-style: italic;">// {title: 'title', link: 'link', description: 'description'}</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> template <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Template</span><span style="color: #009900;">&#40;</span>
            <span style="color: #3366CC;">'&lt;div class=&quot;story&quot;&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'&lt;h3&gt;&lt;a href=&quot;{link}&quot;&gt;{title}&lt;/a&gt;&lt;/h3&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'{description}'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// stories is the id of the empty div on the page</span>
<span style="color: #003366; font-weight: bold;">var</span> stories <span style="color: #339933;">=</span> Ext.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'stories'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Ext.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>Feed.<span style="color: #660066;">data</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    template.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>stories<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This snippet also demonstrates the <code>Ext.each()</code> helper method for iterating over the contents of an array. You can download the full snippet <a href="http://www.sporcic.org/wp-content/uploads/2009/04/feed.zip">here</a> to play with. </p>
<p>As Ext Core is still in beta, there is a disconnect between the API documentation and the actual implementation. If the Ext.Template class is updated to correspond to the documentation, there are also some neat formatting effects that can be applied. For example, instead of the placeholder <code>{description}</code>, you could use <code>{description:ellipsis(20)}</code> which will truncate any string longer than 20 characters and place ellipsis at the end of the string. </p>
<p>I&#8217;ve covered a few of the cool features to make your JavaScript code easier and more maintainable. Ext Core also has some neat OO functionality that I&#8217;ll cover in another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sporcic.org/2009/04/beyond-the-core/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
