<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
>

<channel>
	<title>Solution Hacker &#187; flex</title>
	<atom:link href="http://www.solutionhacker.com/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solutionhacker.com</link>
	<description>This blog provides solutions for enterpreneurs!</description>
	<lastBuildDate>Sun, 05 Feb 2012 00:45:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=228</generator>
<!-- podcast_generator="Blubrry PowerPress/2.0.4" -->
	<itunes:summary>This blog provides solutions for enterpreneurs!</itunes:summary>
	<itunes:author>Solution Hacker</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.solutionhacker.com/wp-content/plugins/powerpress/itunes_default.jpg" />
	<itunes:subtitle>This blog provides solutions for enterpreneurs!</itunes:subtitle>
	<image>
		<title>Solution Hacker &#187; flex</title>
		<url>http://www.solutionhacker.com/wp-content/plugins/powerpress/rss_default.jpg</url>
		<link>http://www.solutionhacker.com</link>
	</image>
		<item>
		<title>Powerful Extension of Flex DataGrid &#8211; Part 1</title>
		<link>http://www.solutionhacker.com/uncategorized/powerful-extension-of-flex-datagrid/</link>
		<comments>http://www.solutionhacker.com/uncategorized/powerful-extension-of-flex-datagrid/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 05:50:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[6. Uncategorized]]></category>
		<category><![CDATA[autocompleted]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=227</guid>
		<description><![CDATA[<h2>Features wanted!</h2>
<p><img height="120" width="120" alt="" src="http://www.solutionhacker.com/wp-content/uploads/image/datagrid.PNG" class="alignleft" />To make Flex datagrid completed, I would like to have the following featues. <strong>AutoCompleted Search</strong> - Locate the data I want quickly if there are too many rows in my grid. <strong>Internationalization</strong> - Handle currency, number and date format. <strong>Data Export</strong> - Output the data in csv format, so users can import to Excel. <strong>Pagination </strong>- If I give the total number of records, the subset of the data rows and the number of rows per page, the grid should be able to do pagination and fire the events when user clicks on other pages. This article I will show you how to make these happen. <!--more--><img onclick="grin(':smile:');" alt=":smile:" src="../../../../../wp-includes/images/smilies/icon_smile.gif" /></p>
<p><!--more--></p>
<h2>AutoCompleted Search</h2>
<p>After you obtain the resultset from the database and pass it back to Flex as list of value objects, Flex, as usual, will convert it to ArrayCollection of value objects and bind it to the datagrid. If you want to filter out the record in the datagrid, you don't need to remove the records from the ArrayCollection. All you need is to provide the implementation of the ArrayCollection's <strong>filterFunction</strong>. Here is the example:&#160;</p>
<pre class="java" name="code">
...
[Bindable]
private var _data:ArrayCollection;

private function init():void
{
	_data = new ArrayCollection(
	[
	{ "name":"One" },
	{ "name":"Two" },
	{ "name":"Three" },
	{ "name":"Four" },
	{ "name":"Five" }
	]);

	_data.filterFunction = filterFunction;
}

private function filterFunction( item:Object ):Boolean
{
	var name:String = String( item.name ).toLowerCase();
	var searchStr:String = textInput.text.toLowerCase();
	return searchStr == name.substr( 0, searchStr.length );
}
//trigger when user type in search string in the text box
private function handleChange():void
{
	//this will iterate the dataset against the filterFunction
	_data.refresh();
}
...
</pre>
<p>Here is the caveat. When using a filterFunction in an ArrayCollection, the Flash Player will always search every item. It is not an effective way. To speed it up, <strong>Hillel Coren</strong> has documented an approach that the subsequent filters will search on the filtered list instead. His approach is elegant and well-documented. Go to his <a href="http://hillelcoren.com/2009/04/17/faster-searching-in-flex-part-2/">article </a>for detailed. The demo is <a href="http://web.me.com/hillelcoren/Site/SearchDemo.html">here</a>. I found Hillel solution quite elegant. Apart from making the search more efficient, his design also modulizes the search code so that it can be unit tested easily.</p>
<p>The idea is to keep the last failed search string in each record. So, if the next search string <strong>begins with</strong> last search string, it is unnecessary to check each fields in the record before you can say it won't be matched.</p>
<pre class="java" name="code">

//---- SearchDemo.mxml ---
private function filterFunction( item:Person ):Boolean
{
	return SearchUtils.isMatch( item, textInput.text );
}

//--- SearchUtils.as ---
public static function isMatch( item:ISearchable, searchStr:String ):Boolean
{
	if (_enableFasterSearch &#38;&#38; !quickCheck( item, searchStr )){
		return false;
	}
			
	var orSearchStrs:Array = searchStr.split( "," );
			
	for each (var orSearchPart:String in orSearchStrs)
	{
		var andSearchStrs:Array = orSearchPart.split( " " );
		var isMatch:Boolean;
				
		for each (var andSearchStr:String in andSearchStrs){
			isMatch = false;					
			for each (var field:String in item.getSearchFields()){
				if (item.matchesField( field, andSearchStr )){
					isMatch = true;
				}	
			}					
			if (!isMatch){break;}
		}	
				
		if (isMatch){
			item.setLastFailedSearchStr( "" );
			return true;
		}
	}			
	item.setLastFailedSearchStr( searchStr );
	return false;			
}
...
</pre>
<p>There are several things worth to mention here. The search routine is generic b/c it is against the item that implements the ISearchable Interface. The item implements this interface will provide the implementation of the matchesField method. So, the generic search routine can focus on providing features on top of it like 'AND', 'OR' filter and quick check algorithm.</p>
<p>NOTE: After you set the filterFunction, you will only get the filtered record if you iterate the ArrayCollection. If you want to get the full dataset, you need to do:&#160;</p>
<pre class="java" name="code">
for each (var obj:Object in arrayCollection.source)  
{  
     // do stuff  
} 
</pre>
<p>Again, thanks for Hillel's tip.</p>
<p>I will talk about Data Export in Part 2 of this series.</p>]]></description>
			<content:encoded><![CDATA[<h2>Features wanted!</h2>
<p><img height="120" width="120" alt="" src="http://www.solutionhacker.com/wp-content/uploads/image/datagrid.PNG" class="alignleft" />To make Flex datagrid completed, I would like to have the following featues. <strong>AutoCompleted Search</strong> &#8211; Locate the data I want quickly if there are too many rows in my grid. <strong>Internationalization</strong> &#8211; Handle currency, number and date format. <strong>Data Export</strong> &#8211; Output the data in csv format, so users can import to Excel. <strong>Pagination </strong>- If I give the total number of records, the subset of the data rows and the number of rows per page, the grid should be able to do pagination and fire the events when user clicks on other pages. This article I will show you how to make these happen. <span id="more-227"></span><img onclick="grin(':smile:');" alt=":smile:" src="../../../../../wp-includes/images/smilies/icon_smile.gif" /></p>
<p><!--more--></p>
<h2>AutoCompleted Search</h2>
<p>After you obtain the resultset from the database and pass it back to Flex as list of value objects, Flex, as usual, will convert it to ArrayCollection of value objects and bind it to the datagrid. If you want to filter out the record in the datagrid, you don&#8217;t need to remove the records from the ArrayCollection. All you need is to provide the implementation of the ArrayCollection&#8217;s <strong>filterFunction</strong>. Here is the example:&#160;</p>
<p><pre><pre class="java" name="code">
...
[Bindable]
private var _data:ArrayCollection;

private function init():void
{
&nbsp;&nbsp;_data = new ArrayCollection(
&nbsp;&nbsp;[
&nbsp;&nbsp;{ &quot;name&quot;:&quot;One&quot; },
&nbsp;&nbsp;{ &quot;name&quot;:&quot;Two&quot; },
&nbsp;&nbsp;{ &quot;name&quot;:&quot;Three&quot; },
&nbsp;&nbsp;{ &quot;name&quot;:&quot;Four&quot; },
&nbsp;&nbsp;{ &quot;name&quot;:&quot;Five&quot; }
&nbsp;&nbsp;]);

&nbsp;&nbsp;_data.filterFunction = filterFunction;
}

private function filterFunction( item:Object ):Boolean
{
&nbsp;&nbsp;var name:String = String( item.name ).toLowerCase();
&nbsp;&nbsp;var searchStr:String = textInput.text.toLowerCase();
&nbsp;&nbsp;return searchStr == name.substr( 0, searchStr.length );
}
//trigger when user type in search string in the text box
private function handleChange():void
{
&nbsp;&nbsp;//this will iterate the dataset against the filterFunction
&nbsp;&nbsp;_data.refresh();
}
...
</pre></pre></p>
<p>Here is the caveat. When using a filterFunction in an ArrayCollection, the Flash Player will always search every item. It is not an effective way. To speed it up, <strong>Hillel Coren</strong> has documented an approach that the subsequent filters will search on the filtered list instead. His approach is elegant and well-documented. Go to his <a href="http://hillelcoren.com/2009/04/17/faster-searching-in-flex-part-2/">article </a>for detailed. The demo is <a href="http://web.me.com/hillelcoren/Site/SearchDemo.html">here</a>. I found Hillel solution quite elegant. Apart from making the search more efficient, his design also modulizes the search code so that it can be unit tested easily.</p>
<p>The idea is to keep the last failed search string in each record. So, if the next search string <strong>begins with</strong> last search string, it is unnecessary to check each fields in the record before you can say it won&#8217;t be matched.</p>
<p><pre><pre class="java" name="code">

//---- SearchDemo.mxml ---
private function filterFunction( item:Person ):Boolean
{
&nbsp;&nbsp;return SearchUtils.isMatch( item, textInput.text );
}

//--- SearchUtils.as ---
public static function isMatch( item:ISearchable, searchStr:String ):Boolean
{
&nbsp;&nbsp;if (_enableFasterSearch &amp;amp;&amp;amp; !quickCheck( item, searchStr )){
&nbsp;&nbsp;&nbsp;&nbsp;return false;
&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;var orSearchStrs:Array = searchStr.split( &quot;,&quot; );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;for each (var orSearchPart:String in orSearchStrs)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;var andSearchStrs:Array = orSearchPart.split( &quot; &quot; );
&nbsp;&nbsp;&nbsp;&nbsp;var isMatch:Boolean;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;for each (var andSearchStr:String in andSearchStrs){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isMatch = false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for each (var field:String in item.getSearchFields()){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (item.matchesField( field, andSearchStr )){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isMatch = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!isMatch){break;}
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;if (isMatch){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item.setLastFailedSearchStr( &quot;&quot; );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;item.setLastFailedSearchStr( searchStr );
&nbsp;&nbsp;return false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}
...
</pre></pre></p>
<p>There are several things worth to mention here. The search routine is generic b/c it is against the item that implements the ISearchable Interface. The item implements this interface will provide the implementation of the matchesField method. So, the generic search routine can focus on providing features on top of it like &#8216;AND&#8217;, &#8216;OR&#8217; filter and quick check algorithm.</p>
<p>NOTE: After you set the filterFunction, you will only get the filtered record if you iterate the ArrayCollection. If you want to get the full dataset, you need to do:&#160;</p>
<p><pre><pre class="java" name="code">
for each (var obj:Object in arrayCollection.source)&nbsp;&nbsp;
{&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; // do stuff&nbsp;&nbsp;
} 
</pre></pre></p>
<p>Again, thanks for Hillel&#8217;s tip.</p>
<p>I will talk about Data Export in Part 2 of this series.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/uncategorized/powerful-extension-of-flex-datagrid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Startup Sequence</title>
		<link>http://www.solutionhacker.com/data-intelligence/report/flex-startup-sequence/</link>
		<comments>http://www.solutionhacker.com/data-intelligence/report/flex-startup-sequence/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 06:56:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Report]]></category>
		<category><![CDATA[dynamic loading theme]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[preloader]]></category>
		<category><![CDATA[startup events]]></category>
		<category><![CDATA[SystemManager]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=217</guid>
		<description><![CDATA[<h2>Magic behind the scene</h2>
<p>I always wonder how my Flex application displayed on the Flash Player in browser. Why decompile Flex SWF will give me <strong>2 frames movie</strong>? What is <strong>SystemManager</strong> and how can I get a handle of it? Many of these kind of questions are at the lower level. The level that makes Flex application possible. Normally, we don't need to dive into this to write a Flex application. However, it would make me feel more comfortable to understand this before I advocate Flex as the main part of our company's UI strategy.&#160;</p>
<p>To understand how your Flex application got loaded and display on Flash Player, you can read this great <a href="http://iamdeepa.com/blog/?p=11">article</a>. I am going to put down the sequences in steps below:</p>
<h2>Flex is a 2-frame movie</h2>
<p>The <strong>first frame</strong> of a Flex SWF contains the <strong>SystemManager</strong>, the <strong>Preloader</strong>, the <strong>DownloadProgressBar </strong>and some glue helper classes. Remember, the Preloader is what creates the DownloadProgressBar control which displays the progress of a Flex application downloading and being initialized. The <strong>second frame</strong> of a Flex SWF contains the rest of the Flex framework code, your application code and all of your application assets like embedded fonts, images, etc.</p>
<p><!--more--><br />
By creating a 2-frame movie, Flex applications can take advantage of the <strong>streaming </strong>support built into the Flash Player and a preloader can appear before all of the Flex framework code and your application code are downloaded.</p>
<blockquote>
<p>The .swf format is a progressive download format which means that Flash player can access content on frames as they download without having to wait for the entire file to download.</p>
</blockquote>
<p><u>Here are the steps</u>:</p>
<ol>
    <li>First, enough bytes for <strong>frame 1</strong> are streamed down to the Flash Player.</li>
    <li>The Flash Player executes those bytes by creating a <strong>SystemManager </strong>instance.</li>
    <li>SystemManager instruct the Flash Player to stop at the end of frame 1.</li>
    <li>SystemManager then goes on to create the <strong>Preloader </strong>which creates the <strong>DownloadProgressBar </strong>control and pops that up on the client screen.</li>
    <li>The Preloader then starts tracking the rest of the bytes streaming in from the Flex SWF.&#160;</li>
    <li>Once all the bytes for the Flex framework and application code are in, the System Manager goes on to frame 2 and instantiates the <strong>Application </strong>instance.</li>
    <li>Once the Application instance has been created, the SystemManager sets <strong>Application.systemManager</strong> to itself. This is how you, the application developer, can access the SystemManager at a later time.</li>
    <li>The Application dispatches the <strong>preinitialize event</strong> at the beginning of the initialization process.</li>
    <li><strong>Application goes on to create its children. </strong>The method createChildren() is called on the application. At this point each of the application’s components is being constructed, and each component’s createChildren() will be also called. For detail, look at <strong>component lifecycle section</strong>.</li>
    <li>The Application dispatches the <strong>initialize event</strong>, which indicates that all application’s components have been initialized. However, at this state,  all the components are not yet laid out.</li>
    <li>Eventually, once all the Application child controls and containers have been created, sized and positioned, the Application dispatches the <strong>creationComplete </strong>event.</li>
    <li>Once the creationComplete event has been dispatched, the Preloader removes the DownloadProgressBar control and the SystemManager <strong>adds the Application instance to the Flash Player display list</strong>. (The Flash Player display list is basically the tree of visible or potentially visible objects that make up your application. When you add and remove child components to your application, your basically just adding and removing them from the display list).</li>
    <li>Once the Application is added to the Flash Player display list, the Application dispatches its <strong>applicationComplete</strong> event</li>
    <li>The Application has been created and is up on the screen ready to be interacted with.<br />
    &#160;</li>
</ol>
<h2>Component Architecture</h2>
<p>&#160;This is the best video I have found that discuss the component lifecycle in detail - Thanks for Deepa.</p>
<embed height="350" width="550" flashvars="v=~b64~aHR0cDovL2Fkb2JlLmVkZ2Vib3NzLm5ldC9mbGFzaC9hZG9iZS9hZG9iZXR2Mi9tYXhfMjAwOF9kZXZlbG9wLzE1OTY3NDE2MTNfMjkzMTA5MzAwMV8yMDAxLS1zdWJyYW1hbmlhbS10dWUtMTMwcG0tZGV2ZWxvcC5mbHY/cnNzX2ZlZWRpZD0xNTM4NCZ4bWx2ZXJzPTI=&#38;w=550&#38;t=http://tv.adobe.com/MAX-2008-Develop/Creating-New-Components-in-Flex-3-by-Deepa-Subramaniam.htmlvi+f15384v1002&#38;h=350" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" quality="high" loop="false" play="true" name="AdobeTVPlayer" bgcolor="#000000" src="http://tv.adobe.com/Embed.swf"></embed>
<p class="MsoNormal" style="text-align: left;">Below is summary I took from the video above, in case you don't want to spend an hour to listen to this. However, I really think you should. To start out, Deepa introduced component and skinning architecture "<strong>Spark</strong>" that is part of Flex 4 <strong>Gumbo</strong>. Spark is built on top of <strong>Halo </strong>(ie. Flex 3 component architecture) and components using Halo or Spark can co-exist. Then,&#160; Deepa put her focus to talk about how to develop her custom video component on top of Halo and Spark for comparison. Spart is great that it can factor out the layout code from component.</p>
<p class="MsoNormal" style="text-align: left;">Halo component lifecycle can be separated into 3 phases:</p>
<p><u><strong>Phase 1 - Initialization</strong></u></p>
<ol>
    <li><u>Construction</u><br />
    <ul>
        <li>Choose the right base class and provide default constructor (ie. zero argument). By extending <strong>UIComponent</strong>, you inherit all of the lifecycle methods, events and properties. Also, since UIComponent extends from <strong>EventDispatcher</strong>, your component inherits the ability to listen and dispatch events.</li>
        <li>Best practice: Call super() and add event listener. Minimal work should occur here.</li>
    </ul>
    </li>
    <li><u>COnfiguration</u>
    <ul>
        <li>setter and getter for properties.</li>
        <li>Involve in invalidation and validation cycle. Detail later.</li>
        <li>Best practice: Setter should not expect the internal children have been created and you want your setter to be fast. Use _xxx for storage variable and have dirty flag for your variable. Throw events out when the internal state of your component get changed.</li>
    </ul>
    </li>
    <li><u>Attachment</u>
    <ul>
        <li>Component are added to the flash <strong>display list </strong>by its parent via <strong>addChild()</strong> call. Without attachment, component lifecycle will be stalled. Nothing is going to happen to your component. So, this is an important step.</li>
        <li>Display list is a tree of visible or potentially visible objects in your application. At the root of the display list is your main application. Thing like containment hierarchy and rendering order are all maintained by the display list.</li>
    </ul>
    </li>
    <li><u>Initialization</u>- 5 lifecycle actions occur here.
    <ul>
        <li><strong>preinitialize </strong>event is dispatched. It signifies that you as component that has been added to the display list by your parent via addChild().</li>
        <li><strong>createChildren()</strong> - walk through all your children, create, configure and attach them to the display list. Best practice: Call super.createChildren(), construct if not exist and attach your children via addChild(). If your child component is dynamic and data driven, use <strong>commitProperties()</strong> b/c it gets called at every invalidation and validation cycle. <em>Halo rules: Container --&#62; nested structure of UIComponents --&#62; MovieClip, Video, Shape and Sprite.</em></li>
        <li><strong>initialize </strong>event is dispatched. It signifies that you and all your children are created and attached.</li>
        <li>First <strong>invalidation/ validation pass </strong>occurs,</li>
        <li><strong>creationComplete</strong> event is dispatched. Ready for prime time.</li>
    </ul>
    </li>
</ol>
<p><u><strong>Phase 2 - Update</strong></u></p>
<p>At this phase, your component is fully initialized and ready for usage. Now, it needs to know how to update. And update occurs when its internal state has been changed by like user interactions. To respond to the changes, component uses the invalidation and validation cycle. The key here is to flag the changed variable dirty during invalidation and later handles it during validation right before rendering. So, you can have many invalidation and one validation that gives better performance via avoiding repetitive work. To better understand this approach, Deepa talks about <strong>Flash Player Elastic Racetrack</strong> that has 2 parts: code execution and rendering. If either part taking too long, Flash player cannot get its job done faster than 1 frame per second. You will see your application with lag and halt, that is bad!&#160;</p>
<ol>
    <li>Invalidation/ Validation can be split into 3 phase. <br />
    <ul>
        <li>InvalidateProperties --&#62; commitProperties</li>
        <li>InvalidateSize --&#62; measure (measure may not be called. Don't have your code depends on it)</li>
        <li>InvalidateDisplayLIst --&#62; updateDisplayList</li>
    </ul>
    </li>
</ol>
<p><u><strong>Phase 3 - Destruction</strong></u></p>
<ol>
    <li>Detachment</li>
    <li>Garbage Collection</li>
</ol>
<p>&#160;</p>
<h2>What is Mixin?</h2>
<p>When you put the [Mixin] metadata just above your class definition and add a static init function to the class like so,</p>
<pre name="code" class="java">
[Mixin]
public class Model {   
	public static function init (systemManager : ISystemManager)   {     
		trace ("I get called first")   
	} 
}
</pre>
<p>The static init function will be called as soon as your application loads (assuming this class is referenced somewhere in the app), much like static initialization blocks in Java. This is useful if you have some code that you want to run before any of the other code in the class.</p>
<h2>Reference</h2>
<p>Below are some interesting articles I found related to this article</p>
<ol>
    <li><a href="http://npacemo.com/wordpress/2008/07/06/flex-application-bootstrapping-totally-custom-preloader/">Create Custom Preloader</a>, <a href="http://www.onflex.org/ted/2006/07/flex-2-custom-preloaders.php">Ted has an article related to this too</a></li>
    <li><a href="http://www.insideria.com/2008/04/flex-ria-performance-considera.html">Speed up startup loading time</a></li>
    <li><a href="http://userflex.wordpress.com/2008/02/07/preload-runtime-styles/">Dynamic loading a new custom theme without fraction seconds delay</a></li>
    <li><a href="http://tv.adobe.com/#vi+f15384v1002">Deepa presentation in MAX</a></li>
    <li><a href="http://www.adobe.com/support/documentation/en/flex/1/mixin/mixin2.html">Introduction to mixins</a></li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Magic behind the scene</h2>
<p>I always wonder how my Flex application displayed on the Flash Player in browser. Why decompile Flex SWF will give me <strong>2 frames movie</strong>? What is <strong>SystemManager</strong> and how can I get a handle of it? Many of these kind of questions are at the lower level. The level that makes Flex application possible. Normally, we don&#8217;t need to dive into this to write a Flex application. However, it would make me feel more comfortable to understand this before I advocate Flex as the main part of our company&#8217;s UI strategy.&#160;</p>
<p>To understand how your Flex application got loaded and display on Flash Player, you can read this great <a href="http://iamdeepa.com/blog/?p=11">article</a>. I am going to put down the sequences in steps below:</p>
<h2>Flex is a 2-frame movie</h2>
<p>The <strong>first frame</strong> of a Flex SWF contains the <strong>SystemManager</strong>, the <strong>Preloader</strong>, the <strong>DownloadProgressBar </strong>and some glue helper classes. Remember, the Preloader is what creates the DownloadProgressBar control which displays the progress of a Flex application downloading and being initialized. The <strong>second frame</strong> of a Flex SWF contains the rest of the Flex framework code, your application code and all of your application assets like embedded fonts, images, etc.</p>
<p><span id="more-217"></span><br />
By creating a 2-frame movie, Flex applications can take advantage of the <strong>streaming </strong>support built into the Flash Player and a preloader can appear before all of the Flex framework code and your application code are downloaded.</p>
<blockquote>
<p>The .swf format is a progressive download format which means that Flash player can access content on frames as they download without having to wait for the entire file to download.</p>
</blockquote>
<p><u>Here are the steps</u>:</p>
<ol>
<li>First, enough bytes for <strong>frame 1</strong> are streamed down to the Flash Player.</li>
<li>The Flash Player executes those bytes by creating a <strong>SystemManager </strong>instance.</li>
<li>SystemManager instruct the Flash Player to stop at the end of frame 1.</li>
<li>SystemManager then goes on to create the <strong>Preloader </strong>which creates the <strong>DownloadProgressBar </strong>control and pops that up on the client screen.</li>
<li>The Preloader then starts tracking the rest of the bytes streaming in from the Flex SWF.&#160;</li>
<li>Once all the bytes for the Flex framework and application code are in, the System Manager goes on to frame 2 and instantiates the <strong>Application </strong>instance.</li>
<li>Once the Application instance has been created, the SystemManager sets <strong>Application.systemManager</strong> to itself. This is how you, the application developer, can access the SystemManager at a later time.</li>
<li>The Application dispatches the <strong>preinitialize event</strong> at the beginning of the initialization process.</li>
<li><strong>Application goes on to create its children. </strong>The method createChildren() is called on the application. At this point each of the application’s components is being constructed, and each component’s createChildren() will be also called. For detail, look at <strong>component lifecycle section</strong>.</li>
<li>The Application dispatches the <strong>initialize event</strong>, which indicates that all application’s components have been initialized. However, at this state,  all the components are not yet laid out.</li>
<li>Eventually, once all the Application child controls and containers have been created, sized and positioned, the Application dispatches the <strong>creationComplete </strong>event.</li>
<li>Once the creationComplete event has been dispatched, the Preloader removes the DownloadProgressBar control and the SystemManager <strong>adds the Application instance to the Flash Player display list</strong>. (The Flash Player display list is basically the tree of visible or potentially visible objects that make up your application. When you add and remove child components to your application, your basically just adding and removing them from the display list).</li>
<li>Once the Application is added to the Flash Player display list, the Application dispatches its <strong>applicationComplete</strong> event</li>
<li>The Application has been created and is up on the screen ready to be interacted with.<br />
    &#160;</li>
</ol>
<h2>Component Architecture</h2>
<p>&#160;This is the best video I have found that discuss the component lifecycle in detail &#8211; Thanks for Deepa.</p>
<p><embed height="350" width="550" flashvars="v=~b64~aHR0cDovL2Fkb2JlLmVkZ2Vib3NzLm5ldC9mbGFzaC9hZG9iZS9hZG9iZXR2Mi9tYXhfMjAwOF9kZXZlbG9wLzE1OTY3NDE2MTNfMjkzMTA5MzAwMV8yMDAxLS1zdWJyYW1hbmlhbS10dWUtMTMwcG0tZGV2ZWxvcC5mbHY/cnNzX2ZlZWRpZD0xNTM4NCZ4bWx2ZXJzPTI=&amp;w=550&amp;t=http://tv.adobe.com/MAX-2008-Develop/Creating-New-Components-in-Flex-3-by-Deepa-Subramaniam.htmlvi+f15384v1002&amp;h=350" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" quality="high" loop="false" play="true" name="AdobeTVPlayer" bgcolor="#000000" src="http://tv.adobe.com/Embed.swf"></embed></p>
<p class="MsoNormal" style="text-align: left;">Below is summary I took from the video above, in case you don&#8217;t want to spend an hour to listen to this. However, I really think you should. To start out, Deepa introduced component and skinning architecture &#8220;<strong>Spark</strong>&#8221; that is part of Flex 4 <strong>Gumbo</strong>. Spark is built on top of <strong>Halo </strong>(ie. Flex 3 component architecture) and components using Halo or Spark can co-exist. Then,&#160; Deepa put her focus to talk about how to develop her custom video component on top of Halo and Spark for comparison. Spart is great that it can factor out the layout code from component.</p>
<p class="MsoNormal" style="text-align: left;">Halo component lifecycle can be separated into 3 phases:</p>
<p><u><strong>Phase 1 &#8211; Initialization</strong></u></p>
<ol>
<li><u>Construction</u>
<ul>
<li>Choose the right base class and provide default constructor (ie. zero argument). By extending <strong>UIComponent</strong>, you inherit all of the lifecycle methods, events and properties. Also, since UIComponent extends from <strong>EventDispatcher</strong>, your component inherits the ability to listen and dispatch events.</li>
<li>Best practice: Call super() and add event listener. Minimal work should occur here.</li>
</ul>
</li>
<li><u>COnfiguration</u>
<ul>
<li>setter and getter for properties.</li>
<li>Involve in invalidation and validation cycle. Detail later.</li>
<li>Best practice: Setter should not expect the internal children have been created and you want your setter to be fast. Use _xxx for storage variable and have dirty flag for your variable. Throw events out when the internal state of your component get changed.</li>
</ul>
</li>
<li><u>Attachment</u>
<ul>
<li>Component are added to the flash <strong>display list </strong>by its parent via <strong>addChild()</strong> call. Without attachment, component lifecycle will be stalled. Nothing is going to happen to your component. So, this is an important step.</li>
<li>Display list is a tree of visible or potentially visible objects in your application. At the root of the display list is your main application. Thing like containment hierarchy and rendering order are all maintained by the display list.</li>
</ul>
</li>
<li><u>Initialization</u>- 5 lifecycle actions occur here.
<ul>
<li><strong>preinitialize </strong>event is dispatched. It signifies that you as component that has been added to the display list by your parent via addChild().</li>
<li><strong>createChildren()</strong> &#8211; walk through all your children, create, configure and attach them to the display list. Best practice: Call super.createChildren(), construct if not exist and attach your children via addChild(). If your child component is dynamic and data driven, use <strong>commitProperties()</strong> b/c it gets called at every invalidation and validation cycle. <em>Halo rules: Container &#8211;&gt; nested structure of UIComponents &#8211;&gt; MovieClip, Video, Shape and Sprite.</em></li>
<li><strong>initialize </strong>event is dispatched. It signifies that you and all your children are created and attached.</li>
<li>First <strong>invalidation/ validation pass </strong>occurs,</li>
<li><strong>creationComplete</strong> event is dispatched. Ready for prime time.</li>
</ul>
</li>
</ol>
<p><u><strong>Phase 2 &#8211; Update</strong></u></p>
<p>At this phase, your component is fully initialized and ready for usage. Now, it needs to know how to update. And update occurs when its internal state has been changed by like user interactions. To respond to the changes, component uses the invalidation and validation cycle. The key here is to flag the changed variable dirty during invalidation and later handles it during validation right before rendering. So, you can have many invalidation and one validation that gives better performance via avoiding repetitive work. To better understand this approach, Deepa talks about <strong>Flash Player Elastic Racetrack</strong> that has 2 parts: code execution and rendering. If either part taking too long, Flash player cannot get its job done faster than 1 frame per second. You will see your application with lag and halt, that is bad!&#160;</p>
<ol>
<li>Invalidation/ Validation can be split into 3 phase. 
<ul>
<li>InvalidateProperties &#8211;&gt; commitProperties</li>
<li>InvalidateSize &#8211;&gt; measure (measure may not be called. Don&#8217;t have your code depends on it)</li>
<li>InvalidateDisplayLIst &#8211;&gt; updateDisplayList</li>
</ul>
</li>
</ol>
<p><u><strong>Phase 3 &#8211; Destruction</strong></u></p>
<ol>
<li>Detachment</li>
<li>Garbage Collection</li>
</ol>
<p>&#160;</p>
<h2>What is Mixin?</h2>
<p>When you put the [Mixin] metadata just above your class definition and add a static init function to the class like so,</p>
<p><pre><pre name="code" class="java">
[Mixin]
public class Model {&nbsp;&nbsp; 
&nbsp;&nbsp;public static function init (systemManager : ISystemManager)&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;trace (&quot;I get called first&quot;)&nbsp;&nbsp; 
&nbsp;&nbsp;} 
}
</pre></pre></p>
<p>The static init function will be called as soon as your application loads (assuming this class is referenced somewhere in the app), much like static initialization blocks in Java. This is useful if you have some code that you want to run before any of the other code in the class.</p>
<h2>Reference</h2>
<p>Below are some interesting articles I found related to this article</p>
<ol>
<li><a href="http://npacemo.com/wordpress/2008/07/06/flex-application-bootstrapping-totally-custom-preloader/">Create Custom Preloader</a>, <a href="http://www.onflex.org/ted/2006/07/flex-2-custom-preloaders.php">Ted has an article related to this too</a></li>
<li><a href="http://www.insideria.com/2008/04/flex-ria-performance-considera.html">Speed up startup loading time</a></li>
<li><a href="http://userflex.wordpress.com/2008/02/07/preload-runtime-styles/">Dynamic loading a new custom theme without fraction seconds delay</a></li>
<li><a href="http://tv.adobe.com/#vi+f15384v1002">Deepa presentation in MAX</a></li>
<li><a href="http://www.adobe.com/support/documentation/en/flex/1/mixin/mixin2.html">Introduction to mixins</a></li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/data-intelligence/report/flex-startup-sequence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Load and stress testing my website</title>
		<link>http://www.solutionhacker.com/implement-your-idea/test-your-website/load-and-stress-testing-my-website/</link>
		<comments>http://www.solutionhacker.com/implement-your-idea/test-your-website/load-and-stress-testing-my-website/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 02:18:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[charles http proxy]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[jmeter]]></category>
		<category><![CDATA[load testing]]></category>
		<category><![CDATA[stress testing]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=209</guid>
		<description><![CDATA[<h2>Purpose of Load and Stress testing</h2>
<p>The key goals of load testing are:</p>
<ol>
	<li>Find out whether your website can support the<strong> expected </strong># of concurrent users.</li>
	<li>At what load does the app break?</li>
</ol>
<p>To do that, you normally follow these steps:</p>
<ol>
	<li>Identifying the primary user path</li>
	<li>Identifying the expected # of concurrent users. (Both now and future)</li>
	<li>Set up virtual users to hit the app (<strong>load generation capability </strong>is the key factor to pick the right tool. You don&#39;t want too much hardware investment to generate the load you want, right? <img alt=":wink:" onclick="grin(':wink:');" src="../../../../../wp-includes/images/smilies/icon_wink.gif" />)</li>
	<li>Run the test</li>
	<li>Analyze the result (throughput under load, avg response time under load)</li>
</ol>
<p>&#160;</p>
<h2><!--more-->Challenges to load test Flex app</h2>
<p>We have a web application that has <strong>Flex </strong>frontend talks to J2EE web application backend via <strong>AMF</strong>. How do we load and stress test this system? We certainly can just perform load test against our backend. However, it may need to expose our service via Servlet and load test it as typical restful web service. If we want to simulate Flex and load test through AMF. We need to find a way to capture the AMF requests from Flex client and replay it in our load testing suite. To do that, we can use <a href="http://www.charlesproxy.com/">Charles http proxy</a> to capture the AMF request and tell <strong>JMeter </strong>to load test our application via replaying this AMF request. This&#160; <a href="http://note19.com/2008/05/06/how-to-use-jmeter-to-load-test-flex-applications/">article</a> can give us the detail. However, Charles is a commerical product. If you want a free solution, you can try <a href="http://90kts.com/blog/2008/performance-testing-flex-remoting-amf-with-jmeter/">this</a>.</p>
<p>I know that JMeter comes with proxy to record the request. You can <a href="http://jakarta.apache.org/jmeter/usermanual/best-practices.html#proxy_server">try it out</a> to see whether you can exam the AMF message. Let me know if it works!</p>
<h2>JMeter</h2>
<p><strong><span class="docEmphasis">Load</span> </strong>is all of the users using your web site at a point in time. Load includes users making requests to your web site as well as those reading pages from previous requests. However, we do need some way of differentiating between all clients and those clients actually making requests to our web site. We use the terms <strong><span class="docEmphasis">concurrent load</span></strong> and <strong><span class="docEmphasis">active load</span></strong> (making request) to make this distinction. We use the <strong>JMeter </strong>to help us to generate the load to our system. In term of load generation, we should make sure that we can simulate the <strong>peak load</strong>. JMeter is a great load testing tool. I have heard that Google is using this to load and stress test its application.</p>
<p><embed allowfullscreen="true" allowscriptaccess="always" id="VideoPlayback" src="http://video.google.co.uk/googleplayer.swf?docid=-6891978643577501895&#38;hl=en&#38;fs=true" style="width: 400px; height: 326px;" type="application/x-shockwave-flash"></embed></p>
<p><u><strong>To use JMeter, follow the steps below:</strong></u></p>
<ol>
	<li><strong>Set up Thread Group</strong> - use to model concurrent virtual users and decide how you want the load be generated.
		<ul>
			<li><strong>Number of threads</strong>.</li>
			<li><strong>The ramp-up period</strong> (it tells JMeter the amount of time for creating the total number of threads). At the beginning of a load test, if the ramp-up period is zero, JMeter will create all the threads at once and send out requests immediately, thus potentially saturating the server and, more importantly, deceivingly increasing the load. That is, the server could become overloaded, not because the average hit rate is high, but because you send all the threads&#39; first requests simultaneously, causing an unusual initial peak hit rate. The rule of thumb for determining a reasonable ramp-up period is to keep the initial hit rate close to the average hit rate.</li>
			<li><strong>The number of times</strong> to execute the test.</li>
			<li>If the client machine running JMeter lacks enough computing power to model a heavy load, JMeter&#39;s <strong>distributive testing feature</strong> allows you to control multiple remote JMeter engines from a single JMeter console.</li>
		</ul>
	</li>
	<li><strong>Introduce user think time</strong></li>
	<li><strong>Specify response-time requirements and validate test results.</strong></li>
</ol>
<p>To get familiar with it, here are some articles I found it useful</p>
<ol>
	<li><a href="http://www.linux.com/feature/34432">Stress testing with JMeter by Daniel Rubio - Linux.com</a></li>
	<li><a href="http://www.devx.com/webdev/Article/17950/0/page/1">Loading testing with Apache JMeter by Kulvir Singh Bhogal, - Devx.com</a></li>
	<li><a href="http://jakarta.apache.org/jmeter/usermanual/jmeter_distributed_testing_step_by_step.pdf">JMeter distributed testing</a></li>
	<li><a href="http://jakarta.apache.org/jmeter/usermanual/jmeter_proxy_step_by_step.pdf">JMeter recording testing</a></li>
	<li><a href="http://www.johnandcailin.com/blog/john/load-test-your-drupal-application-scalability-apache-jmeter">Load test your drupal app scalability with JMeter</a> - Part 1, <a href="http://www.johnandcailin.com/blog/john/load-test-your-drupal-application-scalability-apache-jmeter%3A-part-two">Part 2</a></li>
	<li><a href="http://www.scribd.com/doc/7499267/Load-Testing-With-JMeter">Load testing with JMeter - powerpoint</a> - very good!</li>
	<li><a href="http://www.scribd.com/doc/3805411/Scalability-Factors-of-JMeter-in-Performance-Testing-projects">Scalability Factors of JMeter in Performance Testing</a> - response size, response time, protocol, hardware configuration, load generating tool architecture and configuration, complexity of client-side processing.</li>
	<li><a href="http://www.javaworld.com/javaworld/jw-07-2005/jw-0711-jmeter.html?page=1">JMeter Tips - Javaworld</a></li>
</ol>
<h2>&#160;Reference</h2>
<ol>
	<li>Someone has written a nice <a href="http://flex.sys-con.com/node/614811/mobile">article </a>in sys-con to talk about how to load test Flex application.</li>
	<li><a href="http://mdzyuba.blogspot.com/2008/05/using-flexunit-for-stress-testing.html">Use FlexUnit for stress testing</a></li>
	<li><a href="http://mdzyuba.blogspot.com/2008/05/testing-remote-data-services-with.html">Test Remote Data Service via FlexUnit</a></li>
	<li><a href="http://www.igvita.com/2008/09/30/load-testing-with-log-replay/">Load testing with log replay - interesting idea</a></li>
</ol>
]]></description>
			<content:encoded><![CDATA[<h2>Purpose of Load and Stress testing</h2>
<p>The key goals of load testing are:</p>
<ol>
<li>Find out whether your website can support the<strong> expected </strong># of concurrent users.</li>
<li>At what load does the app break?</li>
</ol>
<p>To do that, you normally follow these steps:</p>
<ol>
<li>Identifying the primary user path</li>
<li>Identifying the expected # of concurrent users. (Both now and future)</li>
<li>Set up virtual users to hit the app (<strong>load generation capability </strong>is the key factor to pick the right tool. You don&#39;t want too much hardware investment to generate the load you want, right? <img alt=":wink:" onclick="grin(':wink:');" src="../../../../../wp-includes/images/smilies/icon_wink.gif" />)</li>
<li>Run the test</li>
<li>Analyze the result (throughput under load, avg response time under load)</li>
</ol>
<p>&nbsp;</p>
<h2><span id="more-209"></span>Challenges to load test Flex app</h2>
<p>We have a web application that has <strong>Flex </strong>frontend talks to J2EE web application backend via <strong>AMF</strong>. How do we load and stress test this system? We certainly can just perform load test against our backend. However, it may need to expose our service via Servlet and load test it as typical restful web service. If we want to simulate Flex and load test through AMF. We need to find a way to capture the AMF requests from Flex client and replay it in our load testing suite. To do that, we can use <a href="http://www.charlesproxy.com/">Charles http proxy</a> to capture the AMF request and tell <strong>JMeter </strong>to load test our application via replaying this AMF request. This&nbsp; <a href="http://note19.com/2008/05/06/how-to-use-jmeter-to-load-test-flex-applications/">article</a> can give us the detail. However, Charles is a commerical product. If you want a free solution, you can try <a href="http://90kts.com/blog/2008/performance-testing-flex-remoting-amf-with-jmeter/">this</a>.</p>
<p>I know that JMeter comes with proxy to record the request. You can <a href="http://jakarta.apache.org/jmeter/usermanual/best-practices.html#proxy_server">try it out</a> to see whether you can exam the AMF message. Let me know if it works!</p>
<h2>JMeter</h2>
<p><strong><span class="docEmphasis">Load</span> </strong>is all of the users using your web site at a point in time. Load includes users making requests to your web site as well as those reading pages from previous requests. However, we do need some way of differentiating between all clients and those clients actually making requests to our web site. We use the terms <strong><span class="docEmphasis">concurrent load</span></strong> and <strong><span class="docEmphasis">active load</span></strong> (making request) to make this distinction. We use the <strong>JMeter </strong>to help us to generate the load to our system. In term of load generation, we should make sure that we can simulate the <strong>peak load</strong>. JMeter is a great load testing tool. I have heard that Google is using this to load and stress test its application.</p>
<p><embed allowfullscreen="true" allowscriptaccess="always" id="VideoPlayback" src="http://video.google.co.uk/googleplayer.swf?docid=-6891978643577501895&amp;hl=en&amp;fs=true" style="width: 400px; height: 326px;" type="application/x-shockwave-flash"></embed></p>
<p><u><strong>To use JMeter, follow the steps below:</strong></u></p>
<ol>
<li><strong>Set up Thread Group</strong> &#8211; use to model concurrent virtual users and decide how you want the load be generated.
<ul>
<li><strong>Number of threads</strong>.</li>
<li><strong>The ramp-up period</strong> (it tells JMeter the amount of time for creating the total number of threads). At the beginning of a load test, if the ramp-up period is zero, JMeter will create all the threads at once and send out requests immediately, thus potentially saturating the server and, more importantly, deceivingly increasing the load. That is, the server could become overloaded, not because the average hit rate is high, but because you send all the threads&#39; first requests simultaneously, causing an unusual initial peak hit rate. The rule of thumb for determining a reasonable ramp-up period is to keep the initial hit rate close to the average hit rate.</li>
<li><strong>The number of times</strong> to execute the test.</li>
<li>If the client machine running JMeter lacks enough computing power to model a heavy load, JMeter&#39;s <strong>distributive testing feature</strong> allows you to control multiple remote JMeter engines from a single JMeter console.</li>
</ul>
</li>
<li><strong>Introduce user think time</strong></li>
<li><strong>Specify response-time requirements and validate test results.</strong></li>
</ol>
<p>To get familiar with it, here are some articles I found it useful</p>
<ol>
<li><a href="http://www.linux.com/feature/34432">Stress testing with JMeter by Daniel Rubio &#8211; Linux.com</a></li>
<li><a href="http://www.devx.com/webdev/Article/17950/0/page/1">Loading testing with Apache JMeter by Kulvir Singh Bhogal, &#8211; Devx.com</a></li>
<li><a href="http://jakarta.apache.org/jmeter/usermanual/jmeter_distributed_testing_step_by_step.pdf">JMeter distributed testing</a></li>
<li><a href="http://jakarta.apache.org/jmeter/usermanual/jmeter_proxy_step_by_step.pdf">JMeter recording testing</a></li>
<li><a href="http://www.johnandcailin.com/blog/john/load-test-your-drupal-application-scalability-apache-jmeter">Load test your drupal app scalability with JMeter</a> &#8211; Part 1, <a href="http://www.johnandcailin.com/blog/john/load-test-your-drupal-application-scalability-apache-jmeter%3A-part-two">Part 2</a></li>
<li><a href="http://www.scribd.com/doc/7499267/Load-Testing-With-JMeter">Load testing with JMeter &#8211; powerpoint</a> &#8211; very good!</li>
<li><a href="http://www.scribd.com/doc/3805411/Scalability-Factors-of-JMeter-in-Performance-Testing-projects">Scalability Factors of JMeter in Performance Testing</a> &#8211; response size, response time, protocol, hardware configuration, load generating tool architecture and configuration, complexity of client-side processing.</li>
<li><a href="http://www.javaworld.com/javaworld/jw-07-2005/jw-0711-jmeter.html?page=1">JMeter Tips &#8211; Javaworld</a></li>
</ol>
<h2>&nbsp;Reference</h2>
<ol>
<li>Someone has written a nice <a href="http://flex.sys-con.com/node/614811/mobile">article </a>in sys-con to talk about how to load test Flex application.</li>
<li><a href="http://mdzyuba.blogspot.com/2008/05/using-flexunit-for-stress-testing.html">Use FlexUnit for stress testing</a></li>
<li><a href="http://mdzyuba.blogspot.com/2008/05/testing-remote-data-services-with.html">Test Remote Data Service via FlexUnit</a></li>
<li><a href="http://www.igvita.com/2008/09/30/load-testing-with-log-replay/">Load testing with log replay &#8211; interesting idea</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/implement-your-idea/test-your-website/load-and-stress-testing-my-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Streaming data to your grid</title>
		<link>http://www.solutionhacker.com/uncategorized/streaming-data-to-your-grid/</link>
		<comments>http://www.solutionhacker.com/uncategorized/streaming-data-to-your-grid/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 00:00:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[6. Uncategorized]]></category>
		<category><![CDATA[Scale]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[liberator]]></category>
		<category><![CDATA[NIO]]></category>
		<category><![CDATA[push]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[thread]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=206</guid>
		<description><![CDATA[<h2>Push data to client</h2>
<p>Traditional web application is based on <strong>request and response model</strong> that information is delivered as a single payload and then immediately close the connection to the client. To keep the client in sync, we normally <strong>pull </strong>the server periodically. This approach may generate unacceptable load to the server. To solve this problem, we want to have a <strong>push </strong>mechanism from server to client. This is why <strong>Comet </strong>is defined. Comet is a generic term describing various approaches to send data asynchronously from a Web server to a client without the need for the client to explicitly request the data. It is an essential technique for any real-time event-driven web applications, where the majority of events occur on the server and data must be "pushed" frequently to the client. To achieve this, Comet servers must maintain <strong>a continuous connection</strong> to each client for the duration of the session.</p>
<div style="page-break-after: always;"><span style="display: none;">&#160;</span></div>
<p>OK. How to maintain <strong>a continuous connection</strong> to each client for the duration of the session?</p>
<blockquote>
<p>If you try to adapt traditional server to the Comet methodology, it may not scale and often fails after a few thousand simultaneously open connections. A true Comet implementation requires a very different kind of server architecture to be efficient and scalable - <a href="http://www.freeliberator.com/comet/">Liberator</a> <em>(a solid Comet server that are used by the financial industries. However, it is written in C and not open source although it has FREE edition distributed). </em></p>
</blockquote>
<p>To understand this statement a little bit more, we need to know how traditional web containers handle the request. They are under <strong>one request per thread </strong>model.</p>
<ol>
    <li>The client , typically , a browser sends request for resource to a web server.</li>
    <li>The server has <strong>a listening thread</strong> that keeps track of incoming connections.</li>
    <li>When a request arrives , the server uses one process or <strong>thread</strong> to process the request.</li>
    <li>The resource is returned to the client and the connection is closed.</li>
</ol>
<p>In this model, the number of requests that can be served in a second would depend on two things</p>
<ol>
    <li>How many threads are there to handle the client requests</li>
    <li>How long it takes to serve one request.</li>
</ol>
<p>If all threads of server are busy, then the incoming requests are <strong>put in a queue</strong>. The server would return to the requests in queue when server threads become free. The number of requests handled per second is always greater than the number of allowed simultaneous connections. All this is made possible because the time required to process a request is very short. In other words you can server more requests in a second than you have threads.</p>
<p>However, there are one breed of applications that need to <strong>hold onto the connections</strong>. Think of applications that require real time data coming to clients (stock tickers)&#160; or think of applications where low-latency is required. In the above traditional web model, the browser has to re-connect to get the new data. (Polling). If the new updates "can"&#160; happen with high frequency (e.g. a chat application) then the polling frequency also has to increase .&#160; An alternative to high frequency polling is to use <strong>push based applications</strong>. For push based application, once the browser connects to server, the server will maintain the connection till the browser time-out (<strong>server response stream is not closed</strong>) and keeps flushing data down the connection as and when they become available. In servlet container, to hold the connection, your thread in the <strong>service </strong>method cannot exit the method. Otherwise, the response stream will be closed. So what you do is, you block the thread on some condition within the service method. So the thread will block for your condition. When push data becomes available , this thread writes to response stream and again enters a blocked state. So as long as you hold onto the connection, you can not return this thread to the thread pool. And as more and more "push" connections are established you would run out of threads! To remedy the problem, the possible solutions are:</p>
<ol>
    <li>Increase # of server threads.</li>
</ol>
<h2>Flex Push</h2>
<p>There is confusion that whether <strong>BlazeDS</strong> supports real time messaging. Yes it does <img onclick="grin(':wink:');" alt=":wink:" src="../../../../../wp-includes/images/smilies/icon_wink.gif" />. In fact, BlazeDS has a full spectrum of channel types ranging from <strong>simple polling</strong>, to <strong>near-real-time polling,</strong> to <strong>real-time streaming</strong>.</p>
<ol>
    <li><strong>Simple polling</strong> - ping the server from Flex client using the traditional request and response model</li>
    <li><strong>Near-real-time polling</strong> (long polling) - Instead of acknowledging right away, the server could hold the polling request until there’s a message for the client. This ensure the messages are delivered to the client as soon as they become available. The caveat for using long-polling is the <strong>thread limitation</strong> in most application servers. At this moment, BlazeDS could not support more than a few hundred long-polling clients on most application servers. However, this problem could be resolved once servers like Tomcat start to support asynchronos, non-blocking connection threads. <span style="color: rgb(255, 0, 0);">Update: Now Tomcat 6 supports NIO.</span></li>
    <li><strong>Real-time streaming</strong> - BlazeDS supports real-time message streaming over AMF and HTTP. Unlike long polling, which closes and reopens the connection upon receiving a message, streaming keep the connection open at all times. Streaming suffers from the same thread blocking issue as long polling. A cap must be set so the server is not hang by idle threads.</li>
</ol>
<p>The reason why people are confused is that Adobe doesn't release its proprietary push solution <a href="http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol">RTMP</a> to BlazeDS. So, RTMP isn't available as a channel in the BlazeDS configuration files. BlazeDS lives in a Servlet container and hence constrained by <strong>one-thread-per-connection</strong> limit whereas <strong>LCDS </strong>has NIO-based channels that can scale up to 1000s of requests. On the other hand, BlazeDS has the advantage that it'll work over port 80/443, whereas LCDS will use some port for persistent connections that would require a firewall configuration. Once the servlet that implements BlazeDS is revved to support Comet Events under Tomcat 6, and then <strong>Jetty Continuations</strong>, then the long polling technique will be fine.</p>
<p><em>UPDATE: We are waiting for a solution that supports Comet Events under Tomcat 6. Then BlazeDS can be coupled to the Tomcat NIO HTTP listener and be able to scale as well as any NIO based server software.</em></p>
<p>I have learnt from this <a href="http://www.flexlive.net/?p=102">article </a>that you can create a <strong>channel set </strong>in client side. So Flex can fail-over to other channels until it gets connected or the list is exhausted.</p>
<p>Marc has put an effort to build a better data grid like a spreadsheet in Flex. (check <a href="http://rockonflash.wordpress.com/2007/11/26/flex-datagrid-replacement/">this </a>out)</p>
<h2>Reference</h2>
<p>Here are the references I used for this article</p>
<ol>
    <li><a href="http://jha.rajeev.googlepages.com/web2push">Tuning Apache and Tomcat for Web 2.0 comet application</a></li>
    <li><a title="Performance of Grids for Streaming Data" rel="bookmark" href="http://cometdaily.com/2007/12/21/performance-of-grids-for-streaming-data/">Performance of Grids for Streaming Data</a> - <em>This shows you the performance numbers on various frontend technologies. Again, Flex shows us a good result.</em></li>
    <li><a href="http://cometdaily.com/2008/11/21/are-raining-comets-and-threads/">Are raining comets and threads? - Comet Daily</a></li>
    <li><a href="http://iobound.com/2008/11/comet-nio/">Comet &#38; Java: Threaded Vs Nonblocking IO </a></li>
    <li><a href="http://pero.blogs.aprilmayjune.org/2009/01/22/hadoop-and-linux-kernel-2627-epoll-limits/">JDK 1.6 uses epoll to implement NIO</a></li>
    <li><a href="http://www.scribd.com/doc/2742051/blazeds-devguide">BlazeDS dev guide</a></li>
    <li><a href="http://www.yachtchartersmagazine.com/node/720304">Achieve performance breakthrough using BlazeDS</a> - <em>Farata System put an effort to write its NIO channel that runs on Jetty 7 and receive promising result.</em></li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Push data to client</h2>
<p>Traditional web application is based on <strong>request and response model</strong> that information is delivered as a single payload and then immediately close the connection to the client. To keep the client in sync, we normally <strong>pull </strong>the server periodically. This approach may generate unacceptable load to the server. To solve this problem, we want to have a <strong>push </strong>mechanism from server to client. This is why <strong>Comet </strong>is defined. Comet is a generic term describing various approaches to send data asynchronously from a Web server to a client without the need for the client to explicitly request the data. It is an essential technique for any real-time event-driven web applications, where the majority of events occur on the server and data must be &#8220;pushed&#8221; frequently to the client. To achieve this, Comet servers must maintain <strong>a continuous connection</strong> to each client for the duration of the session.</p>
<div style="page-break-after: always;"><span style="display: none;">&#160;</span></div>
<p>OK. How to maintain <strong>a continuous connection</strong> to each client for the duration of the session?</p>
<blockquote>
<p>If you try to adapt traditional server to the Comet methodology, it may not scale and often fails after a few thousand simultaneously open connections. A true Comet implementation requires a very different kind of server architecture to be efficient and scalable &#8211; <a href="http://www.freeliberator.com/comet/">Liberator</a> <em>(a solid Comet server that are used by the financial industries. However, it is written in C and not open source although it has FREE edition distributed). </em></p>
</blockquote>
<p>To understand this statement a little bit more, we need to know how traditional web containers handle the request. They are under <strong>one request per thread </strong>model.</p>
<ol>
<li>The client , typically , a browser sends request for resource to a web server.</li>
<li>The server has <strong>a listening thread</strong> that keeps track of incoming connections.</li>
<li>When a request arrives , the server uses one process or <strong>thread</strong> to process the request.</li>
<li>The resource is returned to the client and the connection is closed.</li>
</ol>
<p>In this model, the number of requests that can be served in a second would depend on two things</p>
<ol>
<li>How many threads are there to handle the client requests</li>
<li>How long it takes to serve one request.</li>
</ol>
<p>If all threads of server are busy, then the incoming requests are <strong>put in a queue</strong>. The server would return to the requests in queue when server threads become free. The number of requests handled per second is always greater than the number of allowed simultaneous connections. All this is made possible because the time required to process a request is very short. In other words you can server more requests in a second than you have threads.</p>
<p>However, there are one breed of applications that need to <strong>hold onto the connections</strong>. Think of applications that require real time data coming to clients (stock tickers)&#160; or think of applications where low-latency is required. In the above traditional web model, the browser has to re-connect to get the new data. (Polling). If the new updates &#8220;can&#8221;&#160; happen with high frequency (e.g. a chat application) then the polling frequency also has to increase .&#160; An alternative to high frequency polling is to use <strong>push based applications</strong>. For push based application, once the browser connects to server, the server will maintain the connection till the browser time-out (<strong>server response stream is not closed</strong>) and keeps flushing data down the connection as and when they become available. In servlet container, to hold the connection, your thread in the <strong>service </strong>method cannot exit the method. Otherwise, the response stream will be closed. So what you do is, you block the thread on some condition within the service method. So the thread will block for your condition. When push data becomes available , this thread writes to response stream and again enters a blocked state. So as long as you hold onto the connection, you can not return this thread to the thread pool. And as more and more &#8220;push&#8221; connections are established you would run out of threads! To remedy the problem, the possible solutions are:</p>
<ol>
<li>Increase # of server threads.</li>
</ol>
<h2>Flex Push</h2>
<p>There is confusion that whether <strong>BlazeDS</strong> supports real time messaging. Yes it does <img onclick="grin(':wink:');" alt=":wink:" src="../../../../../wp-includes/images/smilies/icon_wink.gif" />. In fact, BlazeDS has a full spectrum of channel types ranging from <strong>simple polling</strong>, to <strong>near-real-time polling,</strong> to <strong>real-time streaming</strong>.</p>
<ol>
<li><strong>Simple polling</strong> &#8211; ping the server from Flex client using the traditional request and response model</li>
<li><strong>Near-real-time polling</strong> (long polling) &#8211; Instead of acknowledging right away, the server could hold the polling request until there’s a message for the client. This ensure the messages are delivered to the client as soon as they become available. The caveat for using long-polling is the <strong>thread limitation</strong> in most application servers. At this moment, BlazeDS could not support more than a few hundred long-polling clients on most application servers. However, this problem could be resolved once servers like Tomcat start to support asynchronos, non-blocking connection threads. <span style="color: rgb(255, 0, 0);">Update: Now Tomcat 6 supports NIO.</span></li>
<li><strong>Real-time streaming</strong> &#8211; BlazeDS supports real-time message streaming over AMF and HTTP. Unlike long polling, which closes and reopens the connection upon receiving a message, streaming keep the connection open at all times. Streaming suffers from the same thread blocking issue as long polling. A cap must be set so the server is not hang by idle threads.</li>
</ol>
<p>The reason why people are confused is that Adobe doesn&#8217;t release its proprietary push solution <a href="http://en.wikipedia.org/wiki/Real_Time_Messaging_Protocol">RTMP</a> to BlazeDS. So, RTMP isn&#8217;t available as a channel in the BlazeDS configuration files. BlazeDS lives in a Servlet container and hence constrained by <strong>one-thread-per-connection</strong> limit whereas <strong>LCDS </strong>has NIO-based channels that can scale up to 1000s of requests. On the other hand, BlazeDS has the advantage that it&#8217;ll work over port 80/443, whereas LCDS will use some port for persistent connections that would require a firewall configuration. Once the servlet that implements BlazeDS is revved to support Comet Events under Tomcat 6, and then <strong>Jetty Continuations</strong>, then the long polling technique will be fine.</p>
<p><em>UPDATE: We are waiting for a solution that supports Comet Events under Tomcat 6. Then BlazeDS can be coupled to the Tomcat NIO HTTP listener and be able to scale as well as any NIO based server software.</em></p>
<p>I have learnt from this <a href="http://www.flexlive.net/?p=102">article </a>that you can create a <strong>channel set </strong>in client side. So Flex can fail-over to other channels until it gets connected or the list is exhausted.</p>
<p>Marc has put an effort to build a better data grid like a spreadsheet in Flex. (check <a href="http://rockonflash.wordpress.com/2007/11/26/flex-datagrid-replacement/">this </a>out)</p>
<h2>Reference</h2>
<p>Here are the references I used for this article</p>
<ol>
<li><a href="http://jha.rajeev.googlepages.com/web2push">Tuning Apache and Tomcat for Web 2.0 comet application</a></li>
<li><a title="Performance of Grids for Streaming Data" rel="bookmark" href="http://cometdaily.com/2007/12/21/performance-of-grids-for-streaming-data/">Performance of Grids for Streaming Data</a> &#8211; <em>This shows you the performance numbers on various frontend technologies. Again, Flex shows us a good result.</em></li>
<li><a href="http://cometdaily.com/2008/11/21/are-raining-comets-and-threads/">Are raining comets and threads? &#8211; Comet Daily</a></li>
<li><a href="http://iobound.com/2008/11/comet-nio/">Comet &amp; Java: Threaded Vs Nonblocking IO </a></li>
<li><a href="http://pero.blogs.aprilmayjune.org/2009/01/22/hadoop-and-linux-kernel-2627-epoll-limits/">JDK 1.6 uses epoll to implement NIO</a></li>
<li><a href="http://www.scribd.com/doc/2742051/blazeds-devguide">BlazeDS dev guide</a></li>
<li><a href="http://www.yachtchartersmagazine.com/node/720304">Achieve performance breakthrough using BlazeDS</a> &#8211; <em>Farata System put an effort to write its NIO channel that runs on Jetty 7 and receive promising result.</em></li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/uncategorized/streaming-data-to-your-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Annotated Charting</title>
		<link>http://www.solutionhacker.com/data-intelligence/report/flex-annotated-charting/</link>
		<comments>http://www.solutionhacker.com/data-intelligence/report/flex-annotated-charting/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 23:02:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Report]]></category>
		<category><![CDATA[annotation]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[google finance]]></category>
		<category><![CDATA[line chart]]></category>
		<category><![CDATA[range selector]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=201</guid>
		<description><![CDATA[<p>Recently, I want to extend the LineChart in Flex. I want to have line chart with event annotated like Google Finance.</p>
<div align="center"><a href="http://meutzner.com/examples/flex_finance/Flex_Finance_Step5.html" target="_blank">  <img border="0" alt="" src="http://meutzner.com/examples/flex_finance/flex_finance.jpg" /></a></div>
<div align="center">&#160;</div>
<div style="text-align: left;">First of all, I googled the Net to see whether anyone had already done it. It was even better if I could find any open source project related to this. Below are the interesting things I found:</div>
<ol>
    <li><a href="http://www.djindexes.com/DJIA110/learning-center/">Dow Jone Interactive Chart </a>(commerical - it is exactly what I am looking for)</li>
    <li><a href="http://demo.quietlyscheming.com/InteractiveBubble/InteractiveBubble.html">Interactive Bubble Chart</a> (open - although it is not exactly want I want, but if I believe the code can benefit me if I need to customize line chart. <img src="../../../../../wp-includes/images/smilies/icon_cool.gif" alt=":cool:" onclick="grin(':cool:');" /> I may just need to draw the interactive small bubble on the line to get my job done!)</li>
    <li>This <a href="http://demo.quietlyscheming.com/ChartSampler/app.html">demo </a>gives you tons of chart samples. They are all great example although none of them satisfy my current need.</li>
    <li>This <a href="http://www.stretchmedia.ca/blog/index.cfm/2007/3/28/Chart-Milestones-using-annotationElements">demo </a>is close to what I want. From this demo, I notice I can use "<strong>annotationElement</strong>" to draw on top of the data series. However, the trick is to convert the data points to pixel coordinate in order for me to draw something that can move along with the graph even someone stretches it. To make thing easier, Ely Greenfield has created <strong>DataDrawingCanvas </strong>that helps us draw on the chart with only data points specified instead of pixel coordinates. This class extends the <strong>ChartElement </strong>like <strong>AnnotationElement </strong>does (<a href="http://www.quietlyscheming.com/blog/charts/easy-custom-charts/">blog</a>). That is amazing!! Thanks!!! <img onclick="grin(':smile:');" alt=":smile:" src="../../../../../wp-includes/images/smilies/icon_smile.gif" /></li>
    <li><a href="http://meutzner.com/examples/flex_finance/Flex_Finance_Step5.html">Google Finance Chart</a> (It is exactly what I want. I wonder I can get the source of it)<br />
    <ul>
        <li>I have found the blog and <a href="http://meutzner.com/examples/flex_finance/Flex Finance PPT.ppt">powerpoint </a>of this sample (1/7/2009)</li>
        <li>Google uses the Flash/ JavaScript integrate kit to get it works (<a href="http://www.mikechambers.com/blog/2006/03/21/google-finance-flash-ajax-integration/">blog</a>) - I heard that it is very nice combination of Flash and AJAX. This is similar to <a href="http://www.measuremap.com/">MeasureMap</a>'s use of the kit.</li>
        <li>It is open source example!!! (<a href="http://www.meutzner.com/blog/attachments/360/srcview/index.html">code</a>). Thanks for Brendan Meutzner!!</li>
        <li>Brendan also shows us how he created his demo in 5 steps to help us understand how to build it ourselves.</li>
        <li><a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step1.html">Step 1</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step2.html">Step 2</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step3.html">Step 3</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step4.html">Step 4</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step5.html">Step 5</a> - enjoy!!</li>
    </ul>
    </li>
</ol>
<h2>Reference</h2>
<p>Useful resources:</p>
<ol>
    <li><a href="http://tv.adobe.com/#vi+f15384v1024">Data Visualization by Tom Gonzalez</a>. (Tom created an open source visualization framework named Axiis. It looks great. Once I get a chance, I will dig into it) - 7/31/2009</li>
    <li><a href="http://www.onflex.org/ACDS/BuildingAFlexComponent.pdf">Building a Flex Component</a> by Ely GreenField</li>
    <li><a href="http://www.adobe.com/devnet/flex/articles/components_separation.html">Create component and enforce separation of concern</a></li>
    <li><a href="http://www.edwardtufte.com/tufte/">http://www.edwardtufte.com/tufte/ </a>(Edward Tufte - famous guy in data visualization)</li>
    <li><a href="http://www.insideria.com/2008/03/image-manipulation-in-flex.html">http://www.insideria.com/2008/03/image-manipulation-in-flex.html</a> (Image Manipulation)</li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<p>Recently, I want to extend the LineChart in Flex. I want to have line chart with event annotated like Google Finance.</p>
<div align="center"><a href="http://meutzner.com/examples/flex_finance/Flex_Finance_Step5.html" target="_blank">  <img border="0" alt="" src="http://meutzner.com/examples/flex_finance/flex_finance.jpg" /></a></div>
<div align="center">&#160;</div>
<div style="text-align: left;">First of all, I googled the Net to see whether anyone had already done it. It was even better if I could find any open source project related to this. Below are the interesting things I found:</div>
<ol>
<li><a href="http://www.djindexes.com/DJIA110/learning-center/">Dow Jone Interactive Chart </a>(commerical &#8211; it is exactly what I am looking for)</li>
<li><a href="http://demo.quietlyscheming.com/InteractiveBubble/InteractiveBubble.html">Interactive Bubble Chart</a> (open &#8211; although it is not exactly want I want, but if I believe the code can benefit me if I need to customize line chart. <img src="../../../../../wp-includes/images/smilies/icon_cool.gif" alt=":cool:" onclick="grin(':cool:');" /> I may just need to draw the interactive small bubble on the line to get my job done!)</li>
<li>This <a href="http://demo.quietlyscheming.com/ChartSampler/app.html">demo </a>gives you tons of chart samples. They are all great example although none of them satisfy my current need.</li>
<li>This <a href="http://www.stretchmedia.ca/blog/index.cfm/2007/3/28/Chart-Milestones-using-annotationElements">demo </a>is close to what I want. From this demo, I notice I can use &#8220;<strong>annotationElement</strong>&#8221; to draw on top of the data series. However, the trick is to convert the data points to pixel coordinate in order for me to draw something that can move along with the graph even someone stretches it. To make thing easier, Ely Greenfield has created <strong>DataDrawingCanvas </strong>that helps us draw on the chart with only data points specified instead of pixel coordinates. This class extends the <strong>ChartElement </strong>like <strong>AnnotationElement </strong>does (<a href="http://www.quietlyscheming.com/blog/charts/easy-custom-charts/">blog</a>). That is amazing!! Thanks!!! <img onclick="grin(':smile:');" alt=":smile:" src="../../../../../wp-includes/images/smilies/icon_smile.gif" /></li>
<li><a href="http://meutzner.com/examples/flex_finance/Flex_Finance_Step5.html">Google Finance Chart</a> (It is exactly what I want. I wonder I can get the source of it)
<ul>
<li>I have found the blog and <a href="http://meutzner.com/examples/flex_finance/Flex Finance PPT.ppt">powerpoint </a>of this sample (1/7/2009)</li>
<li>Google uses the Flash/ JavaScript integrate kit to get it works (<a href="http://www.mikechambers.com/blog/2006/03/21/google-finance-flash-ajax-integration/">blog</a>) &#8211; I heard that it is very nice combination of Flash and AJAX. This is similar to <a href="http://www.measuremap.com/">MeasureMap</a>&#8216;s use of the kit.</li>
<li>It is open source example!!! (<a href="http://www.meutzner.com/blog/attachments/360/srcview/index.html">code</a>). Thanks for Brendan Meutzner!!</li>
<li>Brendan also shows us how he created his demo in 5 steps to help us understand how to build it ourselves.</li>
<li><a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step1.html">Step 1</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step2.html">Step 2</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step3.html">Step 3</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step4.html">Step 4</a>, <a href="http://www.meutzner.com/blog/attachments/360/Flex_Finance_Step5.html">Step 5</a> &#8211; enjoy!!</li>
</ul>
</li>
</ol>
<h2>Reference</h2>
<p>Useful resources:</p>
<ol>
<li><a href="http://tv.adobe.com/#vi+f15384v1024">Data Visualization by Tom Gonzalez</a>. (Tom created an open source visualization framework named Axiis. It looks great. Once I get a chance, I will dig into it) &#8211; 7/31/2009</li>
<li><a href="http://www.onflex.org/ACDS/BuildingAFlexComponent.pdf">Building a Flex Component</a> by Ely GreenField</li>
<li><a href="http://www.adobe.com/devnet/flex/articles/components_separation.html">Create component and enforce separation of concern</a></li>
<li><a href="http://www.edwardtufte.com/tufte/">http://www.edwardtufte.com/tufte/ </a>(Edward Tufte &#8211; famous guy in data visualization)</li>
<li><a href="http://www.insideria.com/2008/03/image-manipulation-in-flex.html">http://www.insideria.com/2008/03/image-manipulation-in-flex.html</a> (Image Manipulation)</li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/data-intelligence/report/flex-annotated-charting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wiring up Flex, Mate, BlazeDS, Spring, Hibernate and MySQL with Maven 2 &#8211; Part 1</title>
		<link>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/</link>
		<comments>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 10:50:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[5. Fun]]></category>
		<category><![CDATA[6. Uncategorized]]></category>
		<category><![CDATA[Site Building]]></category>
		<category><![CDATA[Team]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[application stack]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[build process]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jetty plugin]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=199</guid>
		<description><![CDATA[<h2>Introduction</h2>
<p>This article is written on top of the great work that&#160;<strong>Sébastien Arbogast </strong>has done. He has written 3 articles that showed you how to wire up Flex, BlazeDS, Spring, Hibernate and MySQL with Maven as build process. I have included his articles below as your reference.</p>
<ol>
    <li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt1.html">The Flex, Spring, and BlazeDS full stack – Part 1: Creating a Flex module</a></li>
    <li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt2.html">The Flex, Spring and BlazeDS full stack – Part 2: Writing the to-do list server</a></li>
    <li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt3.html">The Flex, Spring and BlazeDS full stack – Part 3: Putting the application together</a></li>
</ol>
<p>I have found Sebastien's work as a good foundation for my own project. To contribute back to the community, I will write a series of articles to show you how can customize and extend the todolist sample.</p>
<p><u>What is in the Part 1 of the series...</u></p>
<ol>
    <li>Enhancements on the <strong>Maven </strong>build process
    <ul>
        <li>Leverage <strong>RSL </strong>to factor our the framework swc, so the size of the application swf will be reduced. Apart from that, I also take advantage of <strong>Flash Player Cache</strong> that is available after version 9 update 3 to cache the framework libraries.</li>
        <li>Clean up the Flex and <strong>BlazeDS </strong>dependencies in POM as the latest version of the sdk is available and the BlazeDS dependencies are officially available.</li>
        <li>Include some common reports for maven site generation</li>
        <li>Embed <strong>Jetty</strong> web server in the build process for quick deployment and testing</li>
    </ul>
    </li>
    <li>Document how to get the sample up on <strong>Eclipse </strong>for development<strong><br />
    </strong></li>
    <li>Use <strong>Mate </strong>as Flex framework
    <ul>
        <li>Restructure ToDoList sample to leverage Mate framework</li>
        <li>Factor out Mate as RSL and integrate it with Maven build process via Flex-mojo plugin.</li>
    </ul>
    </li>
</ol>
<p><u>What are in the coming articles...</u></p>
<ol>
    <li>In part 2 of this series, I will show you how to use flex-mojo to build a modular Flex application.</li>
    <li>In part 3 of this series, I will show you how to test your flex app via FlexUnit (Unit test) and FlexMonkey (Functional test)</li>
    <li>In part 4 or this series, I will work on server side. I am planning to add monitoring, caching and security to the server side.</li>
</ol>
<p><!--more--><!--more--></p>
<h2><!--more-->Review "ToDoList" sample</h2>
<p>Before I start my journey, let me highlight what Sebastien has done first:</p>
<ol>
    <li>Sebastien's sample demonstrates how to use Maven as a build process. There are 3 parts or subprojects in his sample. They are:<br />
    <ul>
        <li><strong>todolist-config</strong> (configuration files shared by other subprojects)</li>
        <li><strong>todolist-ria </strong>(Flex frontend)</li>
        <li><strong>todolist-web</strong> (Server side that supports the Frontend)</li>
    </ul>
    </li>
    <li>All these subprojects are considered as <strong>modules </strong>of the main project (root POM). Finally, they are combined together into war artifact and ready to deploy to Tomcat or other J2EE webapp server.</li>
    <li>Flex frontend and backend communicate through a binary RPC protocol - <strong>AMF</strong>. AMF is considered to be the simplest and fastest remoting approach available in Flex. Recently, Adobe has released BlazeDS as an open source implementation of AMF spec. In this sample, <strong>BlazeDS </strong>is used. To use BlazeDS, there are few things you need to do:<br />
    <ul>
        <li>Externalize your POJO service via BlazeDS. This sample shows you how to integrate BlazeDS with Spring</li>
        <li>Make BlazeDS endpoints availabe to the Net via Servlet.</li>
        <li>Have frontend and backend shared the same BlazeDS configuration files.</li>
    </ul>
    </li>
    <li>In this sample, you can also find out how to use <strong>flex-mojo</strong> maven plugin to compile the Flex frontend code into swf. Apart from <a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">flex-mojo plugin</a>, there are other two good plugins worth to mention:<br />
    <ul>
        <li><strong>maven-assembly-plugin </strong>- can be used to bundle all the files under a directory into a zip file. It is used by todolist-config to bundle all the configuration files (<strong>service-config.xml </strong>and <strong>remoting-config.xml</strong>) into a zip during the <strong>package </strong>phase.</li>
        <li><strong>maven-dependency-plugin</strong><strong> - </strong>can be used to unpack the zip file and move to the place you want. It is used by todolist-web to unpack the config zip during the <strong>generate-resources</strong> phase.</li>
    </ul>
    </li>
</ol>
<h2>Enhancements on maven POM</h2>
<p>I have modified the sample's maven pom as follows:</p>
<ul>
    <li>Link to new repository "<strong>Sonatype Forge</strong>" in the root POM. So, I can use the new version of flex-mojo and simplify the todolist-ria adobe framework dependencies. Apart from that, I also take away the private repository from Sebastein because BlazeDS libraries are available in official maven repository (Note: The BlazeDS libraries available in official maven repo are in version 3.0 instead of 3.0.0.544. So, you need to modify the webapp pom correspondingly).</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &#60;repositories&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;repository&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;id&#62;flex-mojos-repository&#60;/id&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;url&#62;http://svn.sonatype.org/flexmojos/repository/&#60;/url&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;true&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;false&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/repository&#62;<br />
&#160;&#160;&#160; &#60;/repositories&#62;<br />
<br />
&#160;&#160;&#160; &#60;pluginRepositories&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;pluginRepository&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;id&#62;flex-mojos-repository&#60;/id&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;url&#62;http://svn.sonatype.org/flexmojos/repository/&#60;/url&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;true&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;false&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/pluginRepository&#62;<br />
&#160;&#160;&#160; &#60;/pluginRepositories&#62;</p>
</blockquote>
<ul>
    <li>Because I link to Sonatype repository, I can have my todolist-ria depends on one flex-framework pom dependency instead of all the swc dependencies. Note that the pom dependency is a way to factor out all the adobe swc dependencies that makes your pom easier to maintain.</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &#160;&#160;&#160; &#60;dependency&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;groupId&#62;com.adobe.flex.framework&#60;/groupId&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;artifactId&#62;flex-framework&#60;/artifactId&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;version&#62;3.1.0.2710&#60;/version&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;type&#62;pom&#60;/type&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#60;/dependency&#62;</p>
</blockquote>
<ul>
    <li>I include mysql driver as dependency in my webapp pom. I think it is cleaner to bundle it in war. I have also added <strong>jetty plugin</strong> in the POM so you have a web server embedded in the build process. With this, you can run this sample application right after you check it out from svn (assume you have maven 2 installed). To start jetty, you can issue the following maven command under your webapp project.</li>
</ul>
<blockquote>
<p>project_root&#62; mvn clean install<br />
project_root/jp-web&#62; mvn jetty:run-war</p>
</blockquote>
<ul>
    <li>I have included some reports that will be shown after site generation. You may not be able to do <strong>mvn site-deploy </strong>because it is linked to my web hosting site. However, you can modify it for your own sake.</li>
</ul>
<h2>Get the sample up on Eclipse</h2>
<p>To develop on Eclipse, you can follow the steps below:</p>
<ol>
    <li>Create Eclipse project file via running the command below at the project root. This will create 2 eclipse projects. One for todolist-ria and one for the webapp. You noticed that I use the <strong>-Declipse.downloadSource=true</strong> to include the source files of my dependencies in my eclipse project. Therefore, I can get to the source code if needed.</li>
</ol>
<blockquote>
<p>mvn -Declipse.downloadSource=true eclipse:eclipse</p>
</blockquote>
<ol>
    <li>Import the projects into Eclipse</li>
    <li>Add new variable<strong> M2_REPO</strong> and set it equals to<strong> [home]/.m2/repository</strong></li>
    <li>If you have installed <strong>Flex Builder plugin</strong> to your Eclipse, you can Add <strong>Flex Project Nature</strong> to the todolist-ria project.
    <ul>
        <li>Select Application Server Type: J2EE</li>
        <li>Put check on "Use remote object access service" with LiveCycle Data Service selected.</li>
        <li>Set up the path. I have my tomcat installed under C:\tools with default <strong>8080 </strong>as port. You should make the changes if you installed it differently.</li>
        <li><img src="http://www.solutionhacker.com/wp-content/uploads/image/flexEclipse1.JPG" style="width: 531px; height: 284px;" alt="" /></li>
        <li>Remove the generated <strong>main.mxml</strong> under the src folder.</li>
        <li>Set <strong>index.mxml </strong>under src folder as default Flex application file to run.</li>
        <li>Use <strong>Default Flex SDK </strong>in Flex Compiler Configuration instead of Server Flex SDK</li>
        <li>Right click and select <strong>Recreate HTML Template</strong> if you see error.</li>
        <li>After all these, you have configured your Flex application pointing to the webapp server and sharing the BlazeDS configuration files. You can verify in Flex Compiler Configuration's Additional Compiler Parameters. See whether you see this: <strong>-services "C:\tools\tomcat-6.0.16\webapps\jp\WEB-INF\flex\services-config.xml" -locale en_US</strong></li>
        <li>Move the war to your tomcat's webapp folder and start it under remote debugging setting. If you are using window, set<strong> DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=n</strong> under your bin/catalina.bat.</li>
        <li>Start your webapp via bin/startup.bat</li>
        <li>Put breakpoint under <strong>TodoServiceImpl</strong> save method and start remote debugger on localhost:8787</li>
        <li>Right click the<strong> index.mxml</strong> and Run As Flex Application.</li>
        <li>Add a new entry and save it on the flex app. <img onclick="grin(':razz:');" alt=":razz:" src="../../../../../wp-includes/images/smilies/icon_razz.gif" /> You should see your remote debugger halt at the breakpoint for you to debug.</li>
        <li>Now you can change your flex code and test it out without leaving your Eclipse. However, if you modify the service in webapp, you need to run "<strong>mvn clean install</strong>" and deploy the war to the tomcat before your flex code can call your server-side code via <strong>AMF</strong>.</li>
    </ul>
    </li>
</ol>
<h2>Use Mate as Framework</h2>
<p>If you are not familiar with Mate, click the image below that moves you to a nice presentation.</p>
<p>&#160;<a href="http://mate.asfusion.com/assets/content//presentations/360_max_presentation.pdf"><img src="http://www.solutionhacker.com/wp-content/uploads/image/mate1.JPG" style="width: 589px; height: 339px;" alt="" /></a></p>
<p><u>What did I do to restructure the todolist sample to make it Mate app?</u></p>
<ol>
    <li>&#160;</li>
</ol>
<h2>Download</h2>
<p>I have made my work available at: <a href="http://www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip">www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip</a></p>
<h2>Reference</h2>
<p>Below are the references I used for the article:</p>
<ol>
    <li><a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">Flex mojo compiler user guide</a></li>
    <li><a href="http://blog.flex-mojos.info/2008/06/04/scopes/">Flex mojo dependency scope rules</a></li>
    <li><a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs">Flex 3 feature introduction: Flex 3 RSL</a></li>
    <li><a href="http://www.adobe.com/devnet/flex/articles/flash_player_cache.html">Improving Flex application performance using Flash Player Cache</a></li>
    <li><a href="http://fna.googlecode.com/svn/trunk/fna/site/mvn_archetypes/index.html">FNA archetype projects&#160;</a></li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>This article is written on top of the great work that&#160;<strong>Sébastien Arbogast </strong>has done. He has written 3 articles that showed you how to wire up Flex, BlazeDS, Spring, Hibernate and MySQL with Maven as build process. I have included his articles below as your reference.</p>
<ol>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt1.html">The Flex, Spring, and BlazeDS full stack – Part 1: Creating a Flex module</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt2.html">The Flex, Spring and BlazeDS full stack – Part 2: Writing the to-do list server</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt3.html">The Flex, Spring and BlazeDS full stack – Part 3: Putting the application together</a></li>
</ol>
<p>I have found Sebastien&#8217;s work as a good foundation for my own project. To contribute back to the community, I will write a series of articles to show you how can customize and extend the todolist sample.</p>
<p><u>What is in the Part 1 of the series&#8230;</u></p>
<ol>
<li>Enhancements on the <strong>Maven </strong>build process
<ul>
<li>Leverage <strong>RSL </strong>to factor our the framework swc, so the size of the application swf will be reduced. Apart from that, I also take advantage of <strong>Flash Player Cache</strong> that is available after version 9 update 3 to cache the framework libraries.</li>
<li>Clean up the Flex and <strong>BlazeDS </strong>dependencies in POM as the latest version of the sdk is available and the BlazeDS dependencies are officially available.</li>
<li>Include some common reports for maven site generation</li>
<li>Embed <strong>Jetty</strong> web server in the build process for quick deployment and testing</li>
</ul>
</li>
<li>Document how to get the sample up on <strong>Eclipse </strong>for development<strong><br />
    </strong></li>
<li>Use <strong>Mate </strong>as Flex framework
<ul>
<li>Restructure ToDoList sample to leverage Mate framework</li>
<li>Factor out Mate as RSL and integrate it with Maven build process via Flex-mojo plugin.</li>
</ul>
</li>
</ol>
<p><u>What are in the coming articles&#8230;</u></p>
<ol>
<li>In part 2 of this series, I will show you how to use flex-mojo to build a modular Flex application.</li>
<li>In part 3 of this series, I will show you how to test your flex app via FlexUnit (Unit test) and FlexMonkey (Functional test)</li>
<li>In part 4 or this series, I will work on server side. I am planning to add monitoring, caching and security to the server side.</li>
</ol>
<p><span id="more-199"></span><!--more--></p>
<h2><!--more-->Review &#8220;ToDoList&#8221; sample</h2>
<p>Before I start my journey, let me highlight what Sebastien has done first:</p>
<ol>
<li>Sebastien&#8217;s sample demonstrates how to use Maven as a build process. There are 3 parts or subprojects in his sample. They are:
<ul>
<li><strong>todolist-config</strong> (configuration files shared by other subprojects)</li>
<li><strong>todolist-ria </strong>(Flex frontend)</li>
<li><strong>todolist-web</strong> (Server side that supports the Frontend)</li>
</ul>
</li>
<li>All these subprojects are considered as <strong>modules </strong>of the main project (root POM). Finally, they are combined together into war artifact and ready to deploy to Tomcat or other J2EE webapp server.</li>
<li>Flex frontend and backend communicate through a binary RPC protocol &#8211; <strong>AMF</strong>. AMF is considered to be the simplest and fastest remoting approach available in Flex. Recently, Adobe has released BlazeDS as an open source implementation of AMF spec. In this sample, <strong>BlazeDS </strong>is used. To use BlazeDS, there are few things you need to do:
<ul>
<li>Externalize your POJO service via BlazeDS. This sample shows you how to integrate BlazeDS with Spring</li>
<li>Make BlazeDS endpoints availabe to the Net via Servlet.</li>
<li>Have frontend and backend shared the same BlazeDS configuration files.</li>
</ul>
</li>
<li>In this sample, you can also find out how to use <strong>flex-mojo</strong> maven plugin to compile the Flex frontend code into swf. Apart from <a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">flex-mojo plugin</a>, there are other two good plugins worth to mention:
<ul>
<li><strong>maven-assembly-plugin </strong>- can be used to bundle all the files under a directory into a zip file. It is used by todolist-config to bundle all the configuration files (<strong>service-config.xml </strong>and <strong>remoting-config.xml</strong>) into a zip during the <strong>package </strong>phase.</li>
<li><strong>maven-dependency-plugin</strong><strong> &#8211; </strong>can be used to unpack the zip file and move to the place you want. It is used by todolist-web to unpack the config zip during the <strong>generate-resources</strong> phase.</li>
</ul>
</li>
</ol>
<h2>Enhancements on maven POM</h2>
<p>I have modified the sample&#8217;s maven pom as follows:</p>
<ul>
<li>Link to new repository &#8220;<strong>Sonatype Forge</strong>&#8221; in the root POM. So, I can use the new version of flex-mojo and simplify the todolist-ria adobe framework dependencies. Apart from that, I also take away the private repository from Sebastein because BlazeDS libraries are available in official maven repository (Note: The BlazeDS libraries available in official maven repo are in version 3.0 instead of 3.0.0.544. So, you need to modify the webapp pom correspondingly).</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &lt;repositories&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;repository&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;id&gt;flex-mojos-repository&lt;/id&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url&gt;http://svn.sonatype.org/flexmojos/repository/&lt;/url&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;true&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;false&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/repository&gt;<br />
&#160;&#160;&#160; &lt;/repositories&gt;</p>
<p>&#160;&#160;&#160; &lt;pluginRepositories&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;pluginRepository&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;id&gt;flex-mojos-repository&lt;/id&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url&gt;http://svn.sonatype.org/flexmojos/repository/&lt;/url&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;true&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;false&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/pluginRepository&gt;<br />
&#160;&#160;&#160; &lt;/pluginRepositories&gt;</p>
</blockquote>
<ul>
<li>Because I link to Sonatype repository, I can have my todolist-ria depends on one flex-framework pom dependency instead of all the swc dependencies. Note that the pom dependency is a way to factor out all the adobe swc dependencies that makes your pom easier to maintain.</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &#160;&#160;&#160; &lt;dependency&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;groupId&gt;com.adobe.flex.framework&lt;/groupId&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;artifactId&gt;flex-framework&lt;/artifactId&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;version&gt;3.1.0.2710&lt;/version&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;type&gt;pom&lt;/type&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &lt;/dependency&gt;</p>
</blockquote>
<ul>
<li>I include mysql driver as dependency in my webapp pom. I think it is cleaner to bundle it in war. I have also added <strong>jetty plugin</strong> in the POM so you have a web server embedded in the build process. With this, you can run this sample application right after you check it out from svn (assume you have maven 2 installed). To start jetty, you can issue the following maven command under your webapp project.</li>
</ul>
<blockquote>
<p>project_root&gt; mvn clean install<br />
project_root/jp-web&gt; mvn jetty:run-war</p>
</blockquote>
<ul>
<li>I have included some reports that will be shown after site generation. You may not be able to do <strong>mvn site-deploy </strong>because it is linked to my web hosting site. However, you can modify it for your own sake.</li>
</ul>
<h2>Get the sample up on Eclipse</h2>
<p>To develop on Eclipse, you can follow the steps below:</p>
<ol>
<li>Create Eclipse project file via running the command below at the project root. This will create 2 eclipse projects. One for todolist-ria and one for the webapp. You noticed that I use the <strong>-Declipse.downloadSource=true</strong> to include the source files of my dependencies in my eclipse project. Therefore, I can get to the source code if needed.</li>
</ol>
<blockquote>
<p>mvn -Declipse.downloadSource=true eclipse:eclipse</p>
</blockquote>
<ol>
<li>Import the projects into Eclipse</li>
<li>Add new variable<strong> M2_REPO</strong> and set it equals to<strong> [home]/.m2/repository</strong></li>
<li>If you have installed <strong>Flex Builder plugin</strong> to your Eclipse, you can Add <strong>Flex Project Nature</strong> to the todolist-ria project.
<ul>
<li>Select Application Server Type: J2EE</li>
<li>Put check on &#8220;Use remote object access service&#8221; with LiveCycle Data Service selected.</li>
<li>Set up the path. I have my tomcat installed under C:\tools with default <strong>8080 </strong>as port. You should make the changes if you installed it differently.</li>
<li><img src="http://www.solutionhacker.com/wp-content/uploads/image/flexEclipse1.JPG" style="width: 531px; height: 284px;" alt="" /></li>
<li>Remove the generated <strong>main.mxml</strong> under the src folder.</li>
<li>Set <strong>index.mxml </strong>under src folder as default Flex application file to run.</li>
<li>Use <strong>Default Flex SDK </strong>in Flex Compiler Configuration instead of Server Flex SDK</li>
<li>Right click and select <strong>Recreate HTML Template</strong> if you see error.</li>
<li>After all these, you have configured your Flex application pointing to the webapp server and sharing the BlazeDS configuration files. You can verify in Flex Compiler Configuration&#8217;s Additional Compiler Parameters. See whether you see this: <strong>-services &#8220;C:\tools\tomcat-6.0.16\webapps\jp\WEB-INF\flex\services-config.xml&#8221; -locale en_US</strong></li>
<li>Move the war to your tomcat&#8217;s webapp folder and start it under remote debugging setting. If you are using window, set<strong> DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=n</strong> under your bin/catalina.bat.</li>
<li>Start your webapp via bin/startup.bat</li>
<li>Put breakpoint under <strong>TodoServiceImpl</strong> save method and start remote debugger on localhost:8787</li>
<li>Right click the<strong> index.mxml</strong> and Run As Flex Application.</li>
<li>Add a new entry and save it on the flex app. <img onclick="grin(':razz:');" alt=":razz:" src="../../../../../wp-includes/images/smilies/icon_razz.gif" /> You should see your remote debugger halt at the breakpoint for you to debug.</li>
<li>Now you can change your flex code and test it out without leaving your Eclipse. However, if you modify the service in webapp, you need to run &#8220;<strong>mvn clean install</strong>&#8221; and deploy the war to the tomcat before your flex code can call your server-side code via <strong>AMF</strong>.</li>
</ul>
</li>
</ol>
<h2>Use Mate as Framework</h2>
<p>If you are not familiar with Mate, click the image below that moves you to a nice presentation.</p>
<p>&#160;<a href="http://mate.asfusion.com/assets/content//presentations/360_max_presentation.pdf"><img src="http://www.solutionhacker.com/wp-content/uploads/image/mate1.JPG" style="width: 589px; height: 339px;" alt="" /></a></p>
<p><u>What did I do to restructure the todolist sample to make it Mate app?</u></p>
<ol>
<li>&#160;</li>
</ol>
<h2>Download</h2>
<p>I have made my work available at: <a href="http://www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip">www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip</a></p>
<h2>Reference</h2>
<p>Below are the references I used for the article:</p>
<ol>
<li><a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">Flex mojo compiler user guide</a></li>
<li><a href="http://blog.flex-mojos.info/2008/06/04/scopes/">Flex mojo dependency scope rules</a></li>
<li><a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs">Flex 3 feature introduction: Flex 3 RSL</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/flash_player_cache.html">Improving Flex application performance using Flash Player Cache</a></li>
<li><a href="http://fna.googlecode.com/svn/trunk/fna/site/mvn_archetypes/index.html">FNA archetype projects&#160;</a></li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking Salesforce &#8211; Part 1 (Resource)</title>
		<link>http://www.solutionhacker.com/fun-stuff/hacking-salesforce-part-1/</link>
		<comments>http://www.solutionhacker.com/fun-stuff/hacking-salesforce-part-1/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 08:59:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[5. Fun]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[platform as service]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[visualforce]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=154</guid>
		<description><![CDATA[<h2>Introduction of Salesforce</h2>
<p><img width="185" height="110" align="left" style="margin-right: 10px;" src="http://www.solutionhacker.com/wp-content/uploads/medium.jpg" alt="" /></p>
<p>My company uses <strong>Salesforce </strong>as its online <strong>CRM </strong>solution. And I happen to be in charge of this team. So, I get a chance to mess around with it. The more I look into it, the more I like the idea and infrastructure behind it. I am not going to dig deep into the beauty of its architecture in this post. Instead, I would post some useful resources to get you to start playing with it. To begin with, I would open a developer account in <a href="http://wiki.apexdevnet.com/events/regular/registration.php?d=70130000000DJmf">force.com</a>. The developer account gives you all the enterprise edition feature with no time limit. The caveats are that&#160; you can only have 1 admin and 1user account, and your account is limited to several MB storage space only. However, it is good enough to get a good taste of Salesforce. After you sign up, you can go to its invaluable <a href="https://wiki.apexdevnet.com/index.php/Wiki">Wiki</a> and <a href="http://community.salesforce.com/sforce?category.id=developers">Discussion Boards</a> to obtain tips and starter tutorials. Salesforce also made 2 ebooks available. They are:</p>
<ol>
    <li><a href="http://wiki.apexdevnet.com/index.php/Creating_On-Demand_Applications:_An_Introduction_to_the_Force.com_Platform">Introduction to the Force.com Platform</a> - for beginner</li>
    <li><a href="http://wiki.apexdevnet.com/index.php/Members:Platform_Cookbook">Force.com Cookbook</a> - for intermediate user</li>
</ol>
<p><!--more--></p>
<p>Now I assume you can do the followings:</p>
<ol>
    <li>Create custom objects and fields via SF UI</li>
    <li>Build object relationships</li>
    <li>Create validation rule and approval process</li>
    <li>Customize the layout for object (very limited without Visualforce)</li>
    <li>Create S-Control</li>
    <li>Mess around with Salesforce Security Model.</li>
</ol>
<p>Great! You are now empowered by Salesforce to build a solution for your company. However, you may encounter issues related to its UI limitation like you cannot hide a field when someone selects a particular field on a picklist (resolved by Visualforce) or you cannot populate another object when one object is saved (resolved by Apex Trigger). You may find a way to get around this problem but I bet it is not going to be pretty. If you are interested to unveil the true power of Salesforce, keep reading.</p>
<h2>Become a expert user</h2>
<p>If you are interested in solving the UI and functionality limitation above, please take a look at the following ebooks:</p>
<ol>
    <li><a href="http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf">Apex Developer&#8217;s Guide</a></li>
    <li><a href="http://www.salesforce.com/us/developer/docs/pages/salesforce_pages_developers_guide.pdf">Visualforce Developer&#8217;s Guide</a></li>
</ol>
<h2>Become a developer</h2>
<p>OK. You are like me, the tools above may not satisfy you completely. To fully control its UI, I would use Flex. To fully manipulate the data model, I would like to use its API. If you are interested in building the next killapp on top of Salesforce platform. Here are some of the <strong>APIs </strong>that you may be interested:</p>
<ol>
    <li><a href="http://www.salesforce.com/us/developer/docs/api/apex_api.pdf">Apex Web Services <span class="caps">API</span></a> &#8211; Covers the <span class="caps">SOAP API</span> in all its glory. I personally wish this was <span class="caps">REST</span>, but <span class="caps">SOAP</span> is better than everything but <span class="caps">REST</span>.</li>
    <li><a href="http://www.salesforce.com/us/developer/docs/api_meta/api_meta.pdf">Apex Metadata <span class="caps">API</span></a> &#8211; A newer <span class="caps">API</span>, the Metadata <span class="caps">API</span> allows us to define the structure (fields and relationships) of our custom objects via <span class="caps">XML</span> rather than via the declarative point-and-click interface. Unfortunately there&#8217;s no Metadata <span class="caps">API</span> available for standard objects (Contacts, Accounts, Opportunities) yet, but I expect that to change this year.</li>
    <li><a href="http://www.salesforce.com/us/developer/docs/ajax/apex_ajax.pdf">Apex <span class="caps">AJAX</span> Toolkit <span class="caps">API</span></a> &#8211; The <span class="caps">AJAX</span> Toolkit is primarily used with S-Controls, which are being phased out in favor of Visualforce. To be honest, the <span class="caps">AJAX</span> Toolkit has always seemed like a workaround hack to me, and hopefully the combination of Visualforce and Apex Code will render it obsolete.</li>
</ol>
<p>I will keep this post updated for the new features Salesfoce releases in the future. <img src="../../../../../wp-includes/images/smilies/icon_mrgreen.gif" alt=":mrgreen:" onclick="grin(':mrgreen:');" /></p>
<p>&#160;&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Introduction of Salesforce</h2>
<p><img width="185" height="110" align="left" style="margin-right: 10px;" src="http://www.solutionhacker.com/wp-content/uploads/medium.jpg" alt="" /></p>
<p>My company uses <strong>Salesforce </strong>as its online <strong>CRM </strong>solution. And I happen to be in charge of this team. So, I get a chance to mess around with it. The more I look into it, the more I like the idea and infrastructure behind it. I am not going to dig deep into the beauty of its architecture in this post. Instead, I would post some useful resources to get you to start playing with it. To begin with, I would open a developer account in <a href="http://wiki.apexdevnet.com/events/regular/registration.php?d=70130000000DJmf">force.com</a>. The developer account gives you all the enterprise edition feature with no time limit. The caveats are that&nbsp; you can only have 1 admin and 1user account, and your account is limited to several MB storage space only. However, it is good enough to get a good taste of Salesforce. After you sign up, you can go to its invaluable <a href="https://wiki.apexdevnet.com/index.php/Wiki">Wiki</a> and <a href="http://community.salesforce.com/sforce?category.id=developers">Discussion Boards</a> to obtain tips and starter tutorials. Salesforce also made 2 ebooks available. They are:</p>
<ol>
<li><a href="http://wiki.apexdevnet.com/index.php/Creating_On-Demand_Applications:_An_Introduction_to_the_Force.com_Platform">Introduction to the Force.com Platform</a> &#8211; for beginner</li>
<li><a href="http://wiki.apexdevnet.com/index.php/Members:Platform_Cookbook">Force.com Cookbook</a> &#8211; for intermediate user</li>
</ol>
<p><span id="more-154"></span></p>
<p>Now I assume you can do the followings:</p>
<ol>
<li>Create custom objects and fields via SF UI</li>
<li>Build object relationships</li>
<li>Create validation rule and approval process</li>
<li>Customize the layout for object (very limited without Visualforce)</li>
<li>Create S-Control</li>
<li>Mess around with Salesforce Security Model.</li>
</ol>
<p>Great! You are now empowered by Salesforce to build a solution for your company. However, you may encounter issues related to its UI limitation like you cannot hide a field when someone selects a particular field on a picklist (resolved by Visualforce) or you cannot populate another object when one object is saved (resolved by Apex Trigger). You may find a way to get around this problem but I bet it is not going to be pretty. If you are interested to unveil the true power of Salesforce, keep reading.</p>
<h2>Become a expert user</h2>
<p>If you are interested in solving the UI and functionality limitation above, please take a look at the following ebooks:</p>
<ol>
<li><a href="http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf">Apex Developer&rsquo;s Guide</a></li>
<li><a href="http://www.salesforce.com/us/developer/docs/pages/salesforce_pages_developers_guide.pdf">Visualforce Developer&rsquo;s Guide</a></li>
</ol>
<h2>Become a developer</h2>
<p>OK. You are like me, the tools above may not satisfy you completely. To fully control its UI, I would use Flex. To fully manipulate the data model, I would like to use its API. If you are interested in building the next killapp on top of Salesforce platform. Here are some of the <strong>APIs </strong>that you may be interested:</p>
<ol>
<li><a href="http://www.salesforce.com/us/developer/docs/api/apex_api.pdf">Apex Web Services <span class="caps">API</span></a> &ndash; Covers the <span class="caps">SOAP API</span> in all its glory. I personally wish this was <span class="caps">REST</span>, but <span class="caps">SOAP</span> is better than everything but <span class="caps">REST</span>.</li>
<li><a href="http://www.salesforce.com/us/developer/docs/api_meta/api_meta.pdf">Apex Metadata <span class="caps">API</span></a> &ndash; A newer <span class="caps">API</span>, the Metadata <span class="caps">API</span> allows us to define the structure (fields and relationships) of our custom objects via <span class="caps">XML</span> rather than via the declarative point-and-click interface. Unfortunately there&rsquo;s no Metadata <span class="caps">API</span> available for standard objects (Contacts, Accounts, Opportunities) yet, but I expect that to change this year.</li>
<li><a href="http://www.salesforce.com/us/developer/docs/ajax/apex_ajax.pdf">Apex <span class="caps">AJAX</span> Toolkit <span class="caps">API</span></a> &ndash; The <span class="caps">AJAX</span> Toolkit is primarily used with S-Controls, which are being phased out in favor of Visualforce. To be honest, the <span class="caps">AJAX</span> Toolkit has always seemed like a workaround hack to me, and hopefully the combination of Visualforce and Apex Code will render it obsolete.</li>
</ol>
<p>I will keep this post updated for the new features Salesfoce releases in the future. <img src="../../../../../wp-includes/images/smilies/icon_mrgreen.gif" alt=":mrgreen:" onclick="grin(':mrgreen:');" /></p>
<p>&nbsp;&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/fun-stuff/hacking-salesforce-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Remoting and Session Management</title>
		<link>http://www.solutionhacker.com/data-intelligence/report/flex-remoting-and-session-management/</link>
		<comments>http://www.solutionhacker.com/data-intelligence/report/flex-remoting-and-session-management/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 10:10:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Report]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/2008/06/22/flex-remoting-and-session-management/</guid>
		<description><![CDATA[<h2>Power of BlazeDS</h2>
<p>Recently, I found out that Adobe has released BlazeDS (subset of LiveCycleDS) that has 4 main advantages:</p>
<ol>
    <li>AS3 to Java object communication (no XML passes back and forth is needed!)</li>
    <li>Boost up performance b/c AMF is a binary protocol</li>
    <li>Built-in proxy support that gets around the cross domain security issue from Flex in ease.</li>
    <li>Allow push messaging</li>
</ol>
<p>I have followed the guideline and set it up. Now my Flex application can call my Java object method without passing xml back and forth. It is awesome! During the setup process, you may experience your flex cannot find the destination set up in the server.</p>
<div class="content"><blockquote>
<p>The error &#8220;[MessagingError message=&#8217;Destination &#8216;SomeBean&#8217; either does not exist or the destination has no channels defined (and the application does not define any default channels.)&#8217;]&#8221;.</p>
</blockquote></div>
<p>The trick here is to add a services argument to the mxmlc call, something of the form below should do the trick!&#160;</p>
<blockquote>
<p>-services &#8220;[local path to your java project]/WEB-INF/flex/services-config.xml&#8221;</p>
</blockquote>
<p>Now you may start enjoying how AS3 talks to your Java Object. However, if&#160; we bypass the Servlet layer in the code, how can we carry session across remote method calls? Great that I have found out how to handle it via this <a href="http://sujitreddyg.wordpress.com/2008/05/16/session-data-management-in-flex-remoting/">article</a>. In short, you can access Session from your Java object via:</p>
<blockquote>
<p>FlexContext.getFlexSession()</p>
</blockquote>
<p>Here is the quote I got from the <a href="http://livedocs.adobe.com/blazeds/1/blazeds_devguide/">BlazeDS developer guide</a>.</p>
<blockquote>
<p>The FlexContext class is useful for getting access to the session and the HTTP pieces of the session, such as the HTTP servlet request and response. This lets you access HTTP data when you use a Flex application in the context of a larger web application where other classes, such as JSPs or Struts actions, might have stored information.</p>
<p>The FlexSession class provides access to an ID and also provides <samp class="codeph">setAttribute</samp> and <samp class="codeph">getAttribute</samp> functionality. This is useful for storing data on the server that doesn't have to go back to the client. However, FlexSession is not cluster-aware; if a client connects to a different server in the cluster, the client receives a new FlexSession. Nothing stored in the FlexSession attributes is persisted for clustering purposes. The FlexSessionListener class is useful for monitoring who is connected. You add a listener by using the static method to track new connections being made. You receive a reference to the session that was added. Each session can then report when it is destroyed to those same listeners. You use this for monitoring connections that close, and also to clean up resources.</p>
</blockquote>
<p>When I looked into the source of FlexContext, I noticed that it leverages <strong>ThreadLocal </strong>to store context info like request, response and session.</p>
<pre name="code" class="java">
    private static ThreadLocal sessions = new ThreadLocal();  
    /**
     * The FlexSession for the current request.  Available for users.
     */
    public static FlexSession getFlexSession()
    {
        return (FlexSession)sessions.get();
    }
</pre>
<h2>Reference</h2>
<p>Below are some of the useful references I have read so far:</p>
<ol>
    <li><a href="http://jim-boone.com/2008/04/10/ria-prototype-client-using-blazeds-messaging-and-jms-j2ee-server/#more-33">Jim Boone's Blog</a></li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Power of BlazeDS</h2>
<p>Recently, I found out that Adobe has released BlazeDS (subset of LiveCycleDS) that has 4 main advantages:</p>
<ol>
<li>AS3 to Java object communication (no XML passes back and forth is needed!)</li>
<li>Boost up performance b/c AMF is a binary protocol</li>
<li>Built-in proxy support that gets around the cross domain security issue from Flex in ease.</li>
<li>Allow push messaging</li>
</ol>
<p>I have followed the guideline and set it up. Now my Flex application can call my Java object method without passing xml back and forth. It is awesome! During the setup process, you may experience your flex cannot find the destination set up in the server.</p>
<div class="content">
<blockquote>
<p>The error &ldquo;[MessagingError message=&rsquo;Destination &lsquo;SomeBean&rsquo; either does not exist or the destination has no channels defined (and the application does not define any default channels.)&rsquo;]&rdquo;.</p>
</blockquote>
</div>
<p>The trick here is to add a services argument to the mxmlc call, something of the form below should do the trick!&nbsp;</p>
<blockquote>
<p>-services &ldquo;[local path to your java project]/WEB-INF/flex/services-config.xml&rdquo;</p>
</blockquote>
<p>Now you may start enjoying how AS3 talks to your Java Object. However, if&nbsp; we bypass the Servlet layer in the code, how can we carry session across remote method calls? Great that I have found out how to handle it via this <a href="http://sujitreddyg.wordpress.com/2008/05/16/session-data-management-in-flex-remoting/">article</a>. In short, you can access Session from your Java object via:</p>
<blockquote>
<p>FlexContext.getFlexSession()</p>
</blockquote>
<p>Here is the quote I got from the <a href="http://livedocs.adobe.com/blazeds/1/blazeds_devguide/">BlazeDS developer guide</a>.</p>
<blockquote>
<p>The FlexContext class is useful for getting access to the session and the HTTP pieces of the session, such as the HTTP servlet request and response. This lets you access HTTP data when you use a Flex application in the context of a larger web application where other classes, such as JSPs or Struts actions, might have stored information.</p>
<p>The FlexSession class provides access to an ID and also provides <samp class="codeph">setAttribute</samp> and <samp class="codeph">getAttribute</samp> functionality. This is useful for storing data on the server that doesn&#8217;t have to go back to the client. However, FlexSession is not cluster-aware; if a client connects to a different server in the cluster, the client receives a new FlexSession. Nothing stored in the FlexSession attributes is persisted for clustering purposes. The FlexSessionListener class is useful for monitoring who is connected. You add a listener by using the static method to track new connections being made. You receive a reference to the session that was added. Each session can then report when it is destroyed to those same listeners. You use this for monitoring connections that close, and also to clean up resources.</p>
</blockquote>
<p>When I looked into the source of FlexContext, I noticed that it leverages <strong>ThreadLocal </strong>to store context info like request, response and session.</p>
<p><pre><pre name="code" class="java">
&nbsp;&nbsp;&nbsp;&nbsp;private static ThreadLocal sessions = new ThreadLocal();&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;/**
&nbsp;&nbsp;&nbsp;&nbsp; * The FlexSession for the current request.&nbsp;&nbsp;Available for users.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;public static FlexSession getFlexSession()
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return (FlexSession)sessions.get();
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre></pre></p>
<h2>Reference</h2>
<p>Below are some of the useful references I have read so far:</p>
<ol>
<li><a href="http://jim-boone.com/2008/04/10/ria-prototype-client-using-blazeds-messaging-and-jms-j2ee-server/#more-33">Jim Boone&#8217;s Blog</a></li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/data-intelligence/report/flex-remoting-and-session-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Power up Salesforce UI via Flex</title>
		<link>http://www.solutionhacker.com/uncategorized/power-up-salesforce-ui-via-flex/</link>
		<comments>http://www.solutionhacker.com/uncategorized/power-up-salesforce-ui-via-flex/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 09:27:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[6. Uncategorized]]></category>
		<category><![CDATA[Report]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[remoting]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[visualforce]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=151</guid>
		<description><![CDATA[<h2>Get started</h2>
<p>Follow the steps below to get your first Flex salesforce app up in Salesforce.</p>
<ol>
    <li><a href="http://www.solutionhacker.com/wp-admin/post-new.php">Register </a>a developer edition account from Salesforce. <strong>Note</strong>: <span id="intelliTxt">Dev account never expires but the account does come with a few limitations. You can only have two users, one an admin account so that you can build and install applications and the other a normal user account so you can test your work from the perspective of a normal user. The account has a <strong>2MB </strong>data limit and you can send mass email. However, It is totally fine for playing around all the features that Salesforce provides. <br />
    </span></li>
    <li><a href="https://wiki.apexdevnet.com/index.php?title=Special:Userlogin&#38;returnto=Members:Flex_Toolkit_download">Download</a> the Flex Salesforce Toolkit (ie. force.com-air_flex-1.0.zip). This toolkit provides the needed <strong>libraries </strong>to communicate  directly with your salesforce.com <strong>database records </strong>from within  a Flex application, using <strong>native ActionScript </strong>packages and  returning strongly typed classes.The documentation on the classes can be found  <a href="http://www.adnsandbox.com/media/flexsdk/docs/index.html">here</a>.</li>
    <li>In this zip file, there is a library called <strong>as3Salesforce.swc</strong> in the bin  directory just off the root of this zip file. It is the library you need to associate to your Flex project.</li>
    <li>Create a Flex project and include the swc library in it.</li>
    <li>You can follow this <a href="http://www.apexdevnet.com/media/FlexArticleScreencast/flexscreencast.swf">screencast </a>to get your first project up.</li>
</ol>
<h2>What you can do after that?</h2>
<p>Now you have your Flex application run locally in Salesforce. Here is my TODO list and the solutions of each one.</p>
<ol>
    <li>Run your app under your own website and pull info from Salesforce using the same api.</li>
    <li>Run your app under Salesforce and have it pulled data from your system thru Flex Remoting (HTTPService, WebService, RemoteObject...etc).</li>
    <li>Can we use the API to pull Salesforce metadata like SControl?</li>
    <li>How can we provide our application via Apex Exchange?
    <ul>
        <li><a href="http://www.oreillynet.com/pub/a/network/2006/11/13/an-introduction-to-saleforcecoms-appexchange.html">Introduction of Salesforce's AppExchange</a></li>
        <li><a href="http://www.oreillynet.com/pub/a/network/2006/11/27/using-the-salesforcecom-api.html">Using Salesforce's API</a></li>
        <li><a href="http://www.oreillynet.com/pub/a/network/2007/01/22/packaging-for-salesforcecom-appexchange.html">Packaging for salesforce's appexchange</a> </li>
    </ul>
    </li>
    <li>How can we use the Salesforce Flex AIR Toolkit to make have your application deal with Salesforce in offline mode? Look into this article.</li>
</ol>
<h2>What Flex gives you but not original Salesforce UI?</h2>
<p>Now you know how to integrate Flex with Salesforce. But what problems that Flex helps us solving but not the original Salesforce UI?</p>
<ol>
    <li>Capture user events on the fly and display additional fields or populate bunch of fields.</li>
    <li>Visual the data via Flex charting.</li>
    <li>Full control on the layout, and look and feel.</li>
</ol>
<p>&#160;&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Get started</h2>
<p>Follow the steps below to get your first Flex salesforce app up in Salesforce.</p>
<ol>
<li><a href="http://www.solutionhacker.com/wp-admin/post-new.php">Register </a>a developer edition account from Salesforce. <strong>Note</strong>: <span id="intelliTxt">Dev account never expires but the account does come with a few limitations. You can only have two users, one an admin account so that you can build and install applications and the other a normal user account so you can test your work from the perspective of a normal user. The account has a <strong>2MB </strong>data limit and you can send mass email. However, It is totally fine for playing around all the features that Salesforce provides. <br />
    </span></li>
<li><a href="https://wiki.apexdevnet.com/index.php?title=Special:Userlogin&amp;returnto=Members:Flex_Toolkit_download">Download</a> the Flex Salesforce Toolkit (ie. force.com-air_flex-1.0.zip). This toolkit provides the needed <strong>libraries </strong>to communicate  directly with your salesforce.com <strong>database records </strong>from within  a Flex application, using <strong>native ActionScript </strong>packages and  returning strongly typed classes.The documentation on the classes can be found  <a href="http://www.adnsandbox.com/media/flexsdk/docs/index.html">here</a>.</li>
<li>In this zip file, there is a library called <strong>as3Salesforce.swc</strong> in the bin  directory just off the root of this zip file. It is the library you need to associate to your Flex project.</li>
<li>Create a Flex project and include the swc library in it.</li>
<li>You can follow this <a href="http://www.apexdevnet.com/media/FlexArticleScreencast/flexscreencast.swf">screencast </a>to get your first project up.</li>
</ol>
<h2>What you can do after that?</h2>
<p>Now you have your Flex application run locally in Salesforce. Here is my TODO list and the solutions of each one.</p>
<ol>
<li>Run your app under your own website and pull info from Salesforce using the same api.</li>
<li>Run your app under Salesforce and have it pulled data from your system thru Flex Remoting (HTTPService, WebService, RemoteObject&#8230;etc).</li>
<li>Can we use the API to pull Salesforce metadata like SControl?</li>
<li>How can we provide our application via Apex Exchange?
<ul>
<li><a href="http://www.oreillynet.com/pub/a/network/2006/11/13/an-introduction-to-saleforcecoms-appexchange.html">Introduction of Salesforce&#8217;s AppExchange</a></li>
<li><a href="http://www.oreillynet.com/pub/a/network/2006/11/27/using-the-salesforcecom-api.html">Using Salesforce&#8217;s API</a></li>
<li><a href="http://www.oreillynet.com/pub/a/network/2007/01/22/packaging-for-salesforcecom-appexchange.html">Packaging for salesforce&#8217;s appexchange</a> </li>
</ul>
</li>
<li>How can we use the Salesforce Flex AIR Toolkit to make have your application deal with Salesforce in offline mode? Look into this article.</li>
</ol>
<h2>What Flex gives you but not original Salesforce UI?</h2>
<p>Now you know how to integrate Flex with Salesforce. But what problems that Flex helps us solving but not the original Salesforce UI?</p>
<ol>
<li>Capture user events on the fly and display additional fields or populate bunch of fields.</li>
<li>Visual the data via Flex charting.</li>
<li>Full control on the layout, and look and feel.</li>
</ol>
<p>&nbsp;&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/uncategorized/power-up-salesforce-ui-via-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Flex for RIA, no AJAX?</title>
		<link>http://www.solutionhacker.com/data-intelligence/report/why-flex-for-ria/</link>
		<comments>http://www.solutionhacker.com/data-intelligence/report/why-flex-for-ria/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 03:12:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Report]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[rpc]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/2007/08/26/why-flex-for-ria/</guid>
		<description><![CDATA[<p>Here is the list of reasons why I chose Flex for the RIA development.</p>
<ol>
    <li><strong>Write Once Deploy Everywhere</strong> - Flex generates SWF that runs on top of Flash Player VM and behaves consistently across different browsers, even mobile phones later. With this, all the browser compatibility issues are basically offloaded by Adobe.</li>
    <li><strong>Solid programming model</strong> with rich widgets and libraries.</li>
    <li><strong>AMF makes Flex object to Java POJO communication possible</strong>. No need to use verbose XML - Check out <strong>BlazeDS</strong>.</li>
    <li><strong>Flex IDE</strong> is a plugin in Eclipse that gives stepwise debugging, UI design console, code completion and more. Working with Actionscript is like Java.</li>
    <li><strong>Flex SDK is open source and free.</strong></li>
    <li><strong>Great support on video streaming</strong></li>
    <li><strong>Integrate with HTML, Javascript and CSS</strong>, so it is not invasive adoption.</li>
    <li><strong>Support offline application via AIR</strong> - Adobe has been working on the <a href="http://labs.adobe.com/technologies/air/">Adobe Integrated Runtime (AIR)</a> that allows for using existing web application development skills to build and deploy desktop applications. <strong>AIR </strong>is still in early development, but promises to allow developers to use their newly learned Flex skills to build desktop applications. No need to learn Swing, Applet...etc.</li>
    <li><strong>Provide several RPC methods</strong> like HTTPService, WebService, AMF and JSON. AMF is 10x faster than SOAP. James Ward developed his Census Flex application to provide performance benchmarks for the different RPC methods in the mainstream RIA technologies. (<a href="http://flexapps.cvs.sourceforge.net/flexapps/census/">Download</a>)</li>
    <li>You can<strong> keep the state in the Flex app</strong> and have your server completely stateless.</li>
    <li>More to come! :)</li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<p>Here is the list of reasons why I chose Flex for the RIA development.</p>
<ol>
<li><strong>Write Once Deploy Everywhere</strong> &#8211; Flex generates SWF that runs on top of Flash Player VM and behaves consistently across different browsers, even mobile phones later. With this, all the browser compatibility issues are basically offloaded by Adobe.</li>
<li><strong>Solid programming model</strong> with rich widgets and libraries.</li>
<li><strong>AMF makes Flex object to Java POJO communication possible</strong>. No need to use verbose XML &#8211; Check out <strong>BlazeDS</strong>.</li>
<li><strong>Flex IDE</strong> is a plugin in Eclipse that gives stepwise debugging, UI design console, code completion and more. Working with Actionscript is like Java.</li>
<li><strong>Flex SDK is open source and free.</strong></li>
<li><strong>Great support on video streaming</strong></li>
<li><strong>Integrate with HTML, Javascript and CSS</strong>, so it is not invasive adoption.</li>
<li><strong>Support offline application via AIR</strong> &#8211; Adobe has been working on the <a href="http://labs.adobe.com/technologies/air/">Adobe Integrated Runtime (AIR)</a> that allows for using existing web application development skills to build and deploy desktop applications. <strong>AIR </strong>is still in early development, but promises to allow developers to use their newly learned Flex skills to build desktop applications. No need to learn Swing, Applet&#8230;etc.</li>
<li><strong>Provide several RPC methods</strong> like HTTPService, WebService, AMF and JSON. AMF is 10x faster than SOAP. James Ward developed his Census Flex application to provide performance benchmarks for the different RPC methods in the mainstream RIA technologies. (<a href="http://flexapps.cvs.sourceforge.net/flexapps/census/">Download</a>)</li>
<li>You can<strong> keep the state in the Flex app</strong> and have your server completely stateless.</li>
<li>More to come! <img src='http://www.solutionhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/data-intelligence/report/why-flex-for-ria/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

