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

<channel>
	<title>CarbonRider &#187; Flex</title>
	<atom:link href="http://www.carbonrider.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.carbonrider.com</link>
	<description>You make a matrix, you define the limits.</description>
	<lastBuildDate>Thu, 19 Jan 2012 04:35:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Flex &#8211; Tab Orientation &#8211; Vertical</title>
		<link>http://flex.carbonrider.com/2011/10/29/flex-tab-orientation-vertical/</link>
		<comments>http://flex.carbonrider.com/2011/10/29/flex-tab-orientation-vertical/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 07:10:11 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Tab]]></category>
		<category><![CDATA[Flex Tab Component]]></category>
		<category><![CDATA[Flex Tab Direction]]></category>
		<category><![CDATA[Flex Tab Orientation]]></category>
		<category><![CDATA[Tab direction]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=550</guid>
		<description><![CDATA[I was looking for a way to change the default orientation of Tabs displayed in TabNavigator and couldn&#8217;t find one. So I thought of looking into the code of mx.containers.TabNavigator to see if it provides any hook to extend the functionality and luckily, I found its possible to change the orientation. Check below sample Code [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2011%2F10%2F29%2Fflex-tab-orientation-vertical%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2011%2F10%2F29%2Fflex-tab-orientation-vertical%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I was looking for a way to change the default orientation of Tabs displayed in TabNavigator and couldn&#8217;t find one. So I thought of looking into the code of mx.containers.TabNavigator to see if it provides any hook to extend the functionality and luckily, I found its possible to change the orientation.<br />
<span id="more-550"></span><br />
Check below sample Code</p>
<pre class="brush:javascript">
package component
{
    import mx.containers.BoxDirection;
    import mx.containers.TabNavigator;
    import mx.core.INavigatorContent;
    import mx.core.UIComponent;
    import mx.core.mx_internal;

    use namespace mx_internal;

    public class MyTabComponent extends TabNavigator
    {
        public function MyTabComponent()
        {
            //TODO: implement function
            super();
        }

        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            if(tabBar!=null)
            {
                tabBar.direction = BoxDirection.VERTICAL;

                for (var i:int = 0; i < numChildren; i++)
                {
                    var containerChild:INavigatorContent =
                        getChildAt(i) as INavigatorContent;

                    if (containerChild)
                    {
                        containerChild.move(tabBar.width, 0);
                        containerChild.setActualSize(unscaledWidth - tabBar.width, unscaledHeight);
                    }
                }
                border.move(tabBar.width, 0);
                border.setActualSize(unscaledWidth - tabBar.width, unscaledHeight);
            }
        }
    }
}
</pre>
<p>Note that this isn't final code and will definately require changes to expose its properties and fine-tune it further, but one can get heads on how to customize tabNavigator. Here is the preview of above component<br />
<img src="http://www.carbonrider.com/wp-content/uploads/2011/10/tab_orientation.png" border="0"/></p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2011/10/29/flex-tab-orientation-vertical/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Builder Extension &#8211; Live Preview of Flex Components</title>
		<link>http://flex.carbonrider.com/2011/08/15/flash-builder-extension-live-preview-of-flex-components/</link>
		<comments>http://flex.carbonrider.com/2011/08/15/flash-builder-extension-live-preview-of-flex-components/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 08:44:56 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Design Preview]]></category>
		<category><![CDATA[Design View Extension]]></category>
		<category><![CDATA[Flash Builder Design View Extension]]></category>
		<category><![CDATA[Flex 4.5 components]]></category>
		<category><![CDATA[Flex 4.5 components live preview]]></category>
		<category><![CDATA[Flex components]]></category>
		<category><![CDATA[Live Preview Flex Components]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=515</guid>
		<description><![CDATA[There is no doubt Flash Builder is one of those IDE, built on top of Eclipse helps you to stop worrying about design time issues and gives a nice editor to paint your application screen. Over last few years, Flash Builder has got rich in functionality and now it provides so many utilities that aid [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2011%2F08%2F15%2Fflash-builder-extension-live-preview-of-flex-components%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2011%2F08%2F15%2Fflash-builder-extension-live-preview-of-flex-components%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>There is no doubt Flash Builder is one of those IDE, built on top of Eclipse helps you to stop worrying about design time issues and gives a nice editor to paint your application screen. Over last few years, Flash Builder has got rich in functionality and now it provides so many utilities that aid developers to build applications quickly. Though this article is not meant for details about the features like Web Service binding, Integration with Server Side Technology like BlazeDS, ColdFusion, Managing DataGrid and DataGrid columns etc., one must have a look at it before spending effort on coding it manually. Well the Aim of this article is not about giving details about what utilities Flash Builder offers to ease development, but one of the strong feature meant for designers/developers which is quite not so popular. &#8211; Design View Extensibility Kit for Flex X.X. (yes the version is marked as X.X, because it has been there for long time.:)<br />
<span id="more-515"></span><br />
In day to day application development, most of the Flex developers create custom components and most of them are meant for visual interaction. While you may have encountered that, the custom components work pretty well at Runtime, there is hardly any design time interaction that you can do. (Ability to interact with component at Design Time &#8211; Flash Builder Design Mode.)<br />
While in most cases, it won&#8217;t look as a constraint, but from User experience point of view, most would like to have that feature incorporated in their component.</p>
<p>So, is thre really an option to interact with components at Design Time, the answer is Yes. Adobe has developed <a href="http://help.adobe.com/en_US/flashbuilder/extensibility/DesignViewExtKitReadme.htm" title="Design View Extensibility Kit for Flex">Design View Extensibility Kit for Flex</a> which one can use to provide live preview of the components &#8211; Yes you can interact with the components in Design Mode.</p>
<p>The above URL provides quite few sample applications, that one can use to experiment and understand how Design View Extensions work in Flash Builder. The sad part is there is no much information available about this Kit (not even enough documentation) and it has been mostly remain hidden, apart from one page article on Adobe site. <img src='http://www.carbonrider.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2011/08/15/flash-builder-extension-live-preview-of-flex-components/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AMF Explorer &#8211; Firefox Add-on to track AMF Messages</title>
		<link>http://flex.carbonrider.com/2010/12/04/amf-explorer-firefox-add-on-to-track-amf-messages/</link>
		<comments>http://flex.carbonrider.com/2010/12/04/amf-explorer-firefox-add-on-to-track-amf-messages/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 05:34:07 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[AMF debugging]]></category>
		<category><![CDATA[AMF Explorer]]></category>
		<category><![CDATA[Debug AMF]]></category>
		<category><![CDATA[Firefox Add-on]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=438</guid>
		<description><![CDATA[Flex Builder (now known as Flash Builder) is definitely a good tool to design and develop Flex applications. It has been quite a while, I have been using Flex Builder And till now my experience says that It is the best tool to develop UI. One having no prior knowledge of designing can still develop [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F12%2F04%2Famf-explorer-firefox-add-on-to-track-amf-messages%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F12%2F04%2Famf-explorer-firefox-add-on-to-track-amf-messages%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Flex Builder (now known as Flash Builder) is definitely a good tool to design and develop Flex applications. It has been quite a while, I have been using Flex Builder And till now my experience says that It is the best tool to develop UI. One having no prior knowledge of designing can still develop pleasant looking UI without a need of putting fancy stuffs. With rich features, Flex makes sure that you spend less time in developing UI.<br />
<span id="more-438"></span><br />
Apart from fancy stuffs, the more important feature of Flex Builder is its debugging capability. Those who have worked with Visual Studio or Eclipse Debugger while developing solution, would feel right at the home. But there is only one problem, you can&#8217;t view AMF messages sent by Flash Player. The time from the AMF message is sent by the Flash Player till it reaches to the Server side object, developers are helpless. Sometimes its very much needed to understand what is being really transmitted over the wires.<br />
While I was also in search of such a tool to track the AMF messages, I stumbled upon &#8211; AMF Explorer (a FireFox Add-on). Those who are using FireBug Add-on, will find it is one more feature available in various options of FireBug. Just search for &#8220;AMF Explorer&#8221; add-on in &#8220;Search&#8221; box of Add-on window, Click &#8220;Add to firefox&#8221; button and you can get started.<br />
Here is the screenshot of a sample application developed using Flash Builder 4 &#038; Flex SDK 4.5 (Hero)<br />
<strong>AMF Request</strong> (Notice the tab &#8220;AMF Request&#8221;)<br />
<img src="http://www.carbonrider.com/wp-content/uploads/2010/12/amf.png" border="0"/></p>
<p><strong>AMF Response</strong> (Notice the tab &#8220;AMF Response&#8221;)<br />
<img src="http://www.carbonrider.com/wp-content/uploads/2010/12/amf_response.png" border="0"/></p>
<p>Here is the URL for &#8220;AMF Explorer&#8221;</p>
<p>https://addons.mozilla.org/en-US/firefox/addon/78928/</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2010/12/04/amf-explorer-firefox-add-on-to-track-amf-messages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex 3 to Flex 4 Migration</title>
		<link>http://flex.carbonrider.com/2010/11/17/flex-3-to-flex-4-migration/</link>
		<comments>http://flex.carbonrider.com/2010/11/17/flex-3-to-flex-4-migration/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 13:55:53 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=427</guid>
		<description><![CDATA[While migrating Flex 3 (SDK 3.4) based project to Flex 4 (SDK 4.5 &#8211; Hero), I came across an issue &#8220;Cannot access properties of null object&#8221; (I don&#8217;t remember the exact error message, but it is somewhat similar). After running the application in debug mode, we found that a variable &#8220;_nonInheritingStyle&#8221; [array] declared in UIComponent [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F11%2F17%2Fflex-3-to-flex-4-migration%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F11%2F17%2Fflex-3-to-flex-4-migration%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>While migrating Flex 3 (SDK 3.4) based project to Flex 4 (SDK 4.5 &#8211; Hero), I came across an issue &#8220;Cannot access properties of null object&#8221; (I don&#8217;t remember the exact error message, but it is somewhat similar). After running the application in debug mode, we found that a variable &#8220;_nonInheritingStyle&#8221; [array] declared in UIComponent is null and ActionScript tried to retrieve value from it. At first instance we thought that the problem could be related to the way stylesheet is loaded and hence instead of loading stylesheet dynamically, we added mx:style tag to the Application. But the problem remained as it is.<br />
<span id="more-427"></span></p>
<p>The next thought was to find out a solution on internet and specific steps to be followed for migration of Flex 3 project to Flex 4. We came across an article from <a href="http://www.adobe.com/devnet/flex/articles/flexbuilder3_to_flashbuilder4.html">Adobe</a> which has detailed explaination for steps to be followed for various scenarios. Though we followed all the steps mentioned in the Article, we continued to experience the same error.</p>
<p>The next step was to put various breakpoints into internal code of framework and findout what is really causing an issue. Finally we found that the problem was specifically occurring when we tried to load a module into Moduleloader (We are having custom moduleloader). After digging more, we found that the StyleManager instance assigned to the newly loaded module factory was differing from the Application and one of its inherited property stylesRoot is having value as null.</p>
<p>Now we found out the problem, the next step was to put an appropriate fix. But I didn&#8217;t found any solution for this and hence I applied following code at the module load to make it working.</p>
<pre code="brush:javascript">
var b:IStyleManager2 = StyleManager.getStyleManager(IFlexModule(a).moduleFactory); //a is instance of the module loaded
b.stylesRoot = styleManager.stylesRoot;
</pre>
<p>Above script must immediately be called once module is loaded.</p>
<p>Though this resolved the problem and application started working, we didnt find any reason for such a behavior. Hence not sure if this is an appropriate fix. Note that the source code we were trying to migrate was written using SDK 3.4 and we didnt check the SDK compatibility checkbox available in Flash Builder 4. There is no error reported if this checkbox is turned on, but we were more interested in leaving it unchecked.</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2010/11/17/flex-3-to-flex-4-migration/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>BlazeDS – SSL – IBM Websphere</title>
		<link>http://flex.carbonrider.com/2010/08/28/blazeds-ssl-ibm-websphere/</link>
		<comments>http://flex.carbonrider.com/2010/08/28/blazeds-ssl-ibm-websphere/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 07:22:59 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[SSL on IBM websphere]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=332</guid>
		<description><![CDATA[No it&#8217;s not one more hate post against IBM websphere, but this time the target is BlazeDS. Few days back, we were facing problem while deploying Flex application on SSL. The environment used for the deployment was IBM websphere 6.1 with IBM JDK and windows 2008. As per BlazeDS documentation, there are very minimal configuration [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F08%2F28%2Fblazeds-ssl-ibm-websphere%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F08%2F28%2Fblazeds-ssl-ibm-websphere%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>No it&#8217;s not one more hate post against IBM websphere, but this time the target is BlazeDS. Few days back, we were facing problem while deploying Flex application on SSL. The environment used for the deployment was IBM websphere 6.1 with IBM JDK and windows 2008. As per BlazeDS documentation, there are very minimal configuration changes required to be done in services-config.xml and other XXX-config.xml files to use secure-amf channel.<br />
<span id="more-332"></span><br />
As per the instruction the configuration was modified to use secure amf channel and the SWF files were recompiled with modified configuration settings. No error messages were displayed at the time of deployment and application startup, but we found strange error message after accessing the application URL. The browser was able to load the SWF and wrapper html file, but it was throwing an error message indicating that SunX509 trust manager is not available.<br />
After enabling BlazeDS logging and careful observation of java stacktrace we found that the actual problem was with the TrustManager implementation of BlazeDS. The default implementation available with BlazeDS is &#8211; EasyX509TrustManager and have a look at the code defined for its constructor</p>
<pre class="brush:java;">
public EasyX509TrustManager(KeyStore keystore)
    throws NoSuchAlgorithmException, KeyStoreException
  {
    <strong>TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509");</strong>
    factory.init(keystore);
    TrustManager[] trustmanagers = factory.getTrustManagers();
    if (trustmanagers.length == 0)
    {
      throw new NoSuchAlgorithmException("SunX509 trust manager not supported");
    }
    this.standardTrustManager = ((X509TrustManager)trustmanagers[0]);
    this.trustStore = (System.getProperty("flex.trustStore") != null);
  }
</pre>
<p>From above code it is quite clear that above code assumes that whole world uses only Sun JVM. While we found the culprit, the next step was to find a fix, so I simply googled &#8220;EasyX509TrustManager IBMX509&#8243; and Voila, google returned only one entry with link to a java code</p>
<pre class="brush:java;">
public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException
    {
        super();
        TrustManagerFactory factory = null;
        try
        {
            factory = TrustManagerFactory.getInstance("SunX509");
        }
        catch (NoSuchAlgorithmException nsae)
        {
            // Fallback attempt - try for an IbmX509 factory in case we're running in WAS with no Sun providers registered.
            try
            {
                factory = TrustManagerFactory.getInstance("IbmX509");
            }
            catch (NoSuchAlgorithmException nsae2)
            {
                throw new NoSuchAlgorithmException("Neither SunX509 nor IbmX509 trust manager supported.");
            }
        }
</pre>
<p>This code is part of latest BlazeDS distribution, so anyone facing above problem make sure that you upgrade the BlazeDS project to latest version. Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2010/08/28/blazeds-ssl-ibm-websphere/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex DataGrid &#8211; Data updates not reflected</title>
		<link>http://flex.carbonrider.com/2010/08/24/flex-datagrid-data-updates-not-reflected/</link>
		<comments>http://flex.carbonrider.com/2010/08/24/flex-datagrid-data-updates-not-reflected/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 16:03:14 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Advanced Datagrid]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[Flex collection update]]></category>
		<category><![CDATA[Flex DataGrid]]></category>
		<category><![CDATA[ItemEditor Collection Update]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=324</guid>
		<description><![CDATA[Flex datagrid is nice option to display data in tabular format and with built-in features like sort, rearrange column position and customize each columns with renderers/editors, it makes developers life easy to built user friendly application in quick time.  But most of the time, those who have coded in Flex, must have noticed that the datagrid [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F08%2F24%2Fflex-datagrid-data-updates-not-reflected%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F08%2F24%2Fflex-datagrid-data-updates-not-reflected%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Flex datagrid is nice option to display data in tabular format and with built-in features like sort, rearrange column position and customize each columns with renderers/editors, it makes developers life easy to built user friendly application in quick time.  But most of the time, those who have coded in Flex, must have noticed that the datagrid just doesnt work properly when row information is updated. Consider following scenario.</p>
<p>1. Datagrid uses ItemEditor to update Collection bound as dataprovider.<br />
2. A change in value of one of the column, involves updates to values displayed in other columns.</p>
<p>In 2nd step, user may change value in one of the column, which will internally result in change in value displayed in other columns. One can easily achieve that using itemEditEnd event but most of the time the updates are not reflected. Consider following code</p>
<pre class="brush: xml;">
<mx:ArrayCollection id="dgArr">
		<mx:Array>
			<mx:Object firstName="Jake" lastName="Tyler" gross="" commPer="" comm="" net="" markAsReadOnly=""/>
			<mx:Object firstName="Ryan" lastName="McCarthy" gross="" commPer="" comm="" net=""  markAsReadOnly=""/>
			<mx:Object firstName="Jill" lastName="Miller" gross="" commPer="" comm="" net=""  markAsReadOnly=""/>
			<mx:Object firstName="John" lastName="Rico" gross="" commPer="" comm="" net=""  markAsReadOnly=""/>
			<mx:Object firstName="Diz" lastName="Watson" gross="" commPer="" comm="" net=""  markAsReadOnly=""/>
			<mx:Object firstName="Lolo" lastName="Hurley" gross="" commPer="" comm="" net=""  markAsReadOnly=""/>
		</mx:Array>
	</mx:ArrayCollection>

	<mx:AdvancedDataGrid dataProvider="{dgArr}" x="100" y="100"
		editable="true" rowCount="5" id="dg"
		itemEditEnd="calculateCommission(event)">
		<mx:groupedColumns>
			<mx:AdvancedDataGridColumn headerText="Read Only" dataField="markAsReadOnly" headerWordWrap="true" editorDataField="selected" editable="true" itemRenderer="mx.controls.CheckBox" rendererIsEditor="true"/>
			<mx:AdvancedDataGridColumn headerText="First Name" dataField="firstName" editable="false"/>
			<mx:AdvancedDataGridColumn headerText="Last Name" dataField="lastName" editable="false"/>
			<mx:AdvancedDataGridColumnGroup headerText="Commission Calculation">
				<mx:AdvancedDataGridColumn dataField="gross" headerText="Gross" itemRenderer="mx.controls.TextInput" rendererIsEditor="true"/>
				<mx:AdvancedDataGridColumn dataField="commPer" headerText="Comm %" itemRenderer="mx.controls.TextInput" rendererIsEditor="true"/>
				<mx:AdvancedDataGridColumn dataField="comm" headerText="Comm" itemRenderer="mx.controls.TextInput" rendererIsEditor="true"/>
				<mx:AdvancedDataGridColumn dataField="net" headerText="Net" itemRenderer="mx.controls.TextInput" rendererIsEditor="true"/>
			</mx:AdvancedDataGridColumnGroup>
		</mx:groupedColumns>
	</mx:AdvancedDataGrid>
</pre>
<p><span id="more-324"></span><br />
Above code just binds one ArrayCollection to datagrid and editable values are displayed in textboxes. The basic requirement is that whenever user enters &#8220;Gross&#8221; and &#8220;Commission %&#8221;, the &#8220;Commission&#8221; and &#8220;Net&#8221; column should be updated. The logic to achieve this is defined in following function</p>
<pre class="brush: javascript;">
private function calculateCommission(evt:AdvancedDataGridEvent):void
{
	if(evt.reason == DataGridEventReason.CANCELLED)
		return;
	var dtIndex:int = evt.currentTarget.selectedIndex;
	var dtField:String = evt.dataField;

	var gross:*, commPer:*, comm:*, net:*;
	var dataGross:* = evt.itemRenderer.data.gross;
	var dataCommPer:* = evt.itemRenderer.data.commPer;
	var dataComm:* = evt.itemRenderer.data.comm;
	var dataNet:* = evt.itemRenderer.data.net;
	switch(dtField)
	{
		case "gross":
			trace("gross column edited.");
			gross = evt.currentTarget.itemEditorInstance.text;
			if( (dataCommPer != null) &#038;&#038; (dataCommPer!="") )
			{
				comm = (gross * dataCommPer) / 100;
				net = gross - comm;
			}else if( (dataComm != null) &#038;&#038; (dataComm!=""))
			{
				commPer = (dataComm * 100) / gross;
				net = gross - dataComm;
			}else{
				net = gross;
			}
			break;
		case "commPer":
			trace("comm % column edited.");
			commPer = evt.currentTarget.itemEditorInstance.text;
			if( (dataGross != null) &#038;&#038; (dataGross!="") )
			{
				comm = dataGross * (commPer / 100);
				net = dataGross - comm;
			}
			break;
		case "comm":
			trace("comm column edited.");
			comm = evt.currentTarget.itemEditorInstance.text;
			if( (dataGross != null) &#038;&#038; (dataGross!="") )
			{
				commPer = (100 * comm) / dataGross;
				net = dataGross - comm;
			}
			break;
		case "net":
			trace("net column edited.");
			net = evt.currentTarget.itemEditorInstance.text;
			break;
		}

		var item:Object = evt.currentTarget.dataProvider.getItemAt(dtIndex);

		if(gross!=null)
			item.gross = gross;
		if(commPer!=null)
			item.commPer = commPer;
		if(comm!=null)
			item.comm = comm;
		if(net!=null)
			item.net = net;
		evt.currentTarget.dataProvider.itemUpdated(item);
		}
</pre>
<p>(Note that above code is not completed but used for illustration purpose). Above code updates values in respective properties of given item and invokes itemUpdated function on underlying ArrayCollection. If you run the application, you might notice that the application behaves unexpectadly. Sometimes the values are updated and sometimes it wont update value. To resolve this issue, comment &#8220;itemUpdated&#8221; function call and add following code.</p>
<pre class="brush: javascript;">
var colEvent:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE,
true,false, CollectionEventKind.UPDATE);
colEvent.items = [item];
colEvent.location =  dtIndex;
(evt.currentTarget.dataProvider as ArrayCollection).dispatchEvent(colEvent);
</pre>
<p>You will now notice that everytime you update the column values, the changes are reflected properly. Above code will work in all scenarios, except one. To simulate that issue, perform following steps</p>
<p>1. Enter some values in all the rows.<br />
2. Click on textbox displayed for &#8220;Commission&#8221; column of 1st row.<br />
3. Without changing any value, now select &#8220;Gross&#8221; column textbox of 2nd row with left button of mouse.<br />
4. Change the value displayed in &#8220;Gross&#8221; textbox of 2nd row and tab out. You will notice that tab will focus on 1st row rather than moving to next textbox.</p>
<p>The reason behind such unexpected behavior is that when user directly selects the value in any of the editable column, the datagrid controls is not able to track the event and hence the itemEditedPosition property is not set.<br />
To make above code work, you should modify the itemRenderer attribute in above code and create one mxml renderer component. Refer to following code.</p>
<pre class="brush: xml;">
<mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml" focusIn="setItemEditedPosition(event)">
	<mx:Script>
		<![CDATA[
			import mx.controls.AdvancedDataGrid;
			import mx.controls.listClasses.IListItemRenderer;
			import mx.controls.DataGrid;
			private function setItemEditedPosition(evt:FocusEvent):void
			{
				var dg:AdvancedDataGrid = this.listData.owner as AdvancedDataGrid;

				dg.editedItemPosition = {rowIndex: this.listData.rowIndex,columnIndex:this.listData.columnIndex};
			}
		]]&gt;
	</mx:Script>
</mx:TextInput>
</pre>
<p>I would name this file as &#8220;AmountInput.mxml&#8221; and change itemRenderer Attribute of the datagridcolumn to point this new component.<br />
Build the project and run it. Now you would notice that the data updations are reflected properly.</p>
<p>Hope this helps !</p>
<p>Updated : Thought of putting source code for this example, to download the source code just <a href="http://www.carbonrider.com/wp-content/uploads/2010/09/src.zip">click here</a>. I am using Flex SDK 3.4 with target flash player version as 10.0.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2010/08/24/flex-datagrid-data-updates-not-reflected/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Extending Flex Builder 3 &#8211; Building eclipse plugin</title>
		<link>http://flex.carbonrider.com/2010/05/02/extending-flex-builder-3-building-eclipse-plugin/</link>
		<comments>http://flex.carbonrider.com/2010/05/02/extending-flex-builder-3-building-eclipse-plugin/#comments</comments>
		<pubDate>Sun, 02 May 2010 12:06:28 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Eclipse plugin]]></category>
		<category><![CDATA[extend flex builder]]></category>
		<category><![CDATA[Flex Builder plugin]]></category>
		<category><![CDATA[Flex plugin]]></category>

		<guid isPermaLink="false">http://flex.carbonrider.com/?p=274</guid>
		<description><![CDATA[As mentioned in earlier post, I have been playing with FLEX builder and understand its extensibility APIs. After spending almost day crawling through various search engines and websites I couldn&#8217;t find a single site giving me details about how to work with MXML design editor APIs, I thought of giving up. But fortunately I could [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F05%2F02%2Fextending-flex-builder-3-building-eclipse-plugin%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F05%2F02%2Fextending-flex-builder-3-building-eclipse-plugin%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>As mentioned in earlier post, I have been playing with FLEX builder and understand its extensibility APIs. After spending almost day crawling through various search engines and websites I couldn&#8217;t find a single site giving me details about how to work with MXML design editor APIs, I thought of giving up. But fortunately I could able to figure out how things actually work in FLEX Builder, and then I thought of publishing some of the details through the blog.</p>
<p>The next few paragraphs will talk about various APIs and options available in FLEX builder which can be used by anyone to build their own plugin in Flex Builder. While the title of the post says that &#8220;Building eclipse plugin&#8221;, it surely doesn&#8217;t describe basic steps required to build eclipse plugin. To learn basics of building eclipse plugin, you should visit other sites like java2s and yeah offcourse eclipse itself has plethora of information on building plugin.</p>
<p>The aim of this article is to give details about the editor used to design Flex layouts. You must have used plugins which can generate AS code, ident XML code etc in Flex builder but there are very few plugins which actually work on design editor.<br />
Before writing any plugin code you need to make sure that you have the required environment set for plugin development. Though Eclipse comes with built in feature of plugin development, Flex builder doesn&#8217;t have built-in support for Java and plugin development project. So to get started with plugin development you need to first install plugin development and Java development feature into Flex builder. Keep it in mind that we need to build plugin inside Flex Builder, the simple reason behind this is to test your plugin code we will require sample workspace of Flex builder and that can be easily started through Flex builder. The installation of Java and Plugin development feature is only required if Flex Builder is installed as Standalone version. If you have installed Flex Builder in Eclipse you can skip this installation.</p>
<p>The next step is to add required Extensions and Jar files in plugin project. Make sure that you have added extensions listed in following image.</p>
<p><img src="http://www.carbonrider.com/wp-content/uploads/2010/05/flex_extensions.jpg" alt="Flex builder extensions" /></p>
<p>Apart from adding above extensions you will need 3 additional Jar files which contain useful APIs. The filenames are derived.jar, mxml.jar and mxmlmodel.jar. You need to search these files in Flex plugins. Now create a default &#8220;view&#8221; using Plugin wizard available in Eclipse.<br />
The wizard should create all the files required to build plugin.</p>
<p>Lets directly jump into java code and see how you can get the reference of MXML editor itself</p>
<pre class="brush: java;">
MXMLEditor a = (MXMLEditor)getSite().getPage().getActiveEditor();
</pre>
<p>Above statement will give you the reference of current MXML editor. You need to be bit careful while using this statement as user may not always work with MXML editor (There is action script editor or user may switch from one MXML file to another or may even switch from design view to source code). So you need to logically place this code to get reference of MXML editor.<br />
(Hint: Try to find out details about IPartListener.)</p>
<p>The editor object is pretty much useful to listen to the events raised in editor. An editor instance has a method called getMXMLModel which represents an MXML instance for the editor. You can use the IMXMLModel instance returned by getMXMLModel method to manipulate MXML code. The reference also provides a convenient method to listen to the user selection in design view.<br />
Just place below code after getting IMXMLModel reference</p>
<pre class="brush:java">
mm.getSelectionProvider().addSelectionChangedListener(new SelectionChangeListener())
</pre>
<p>Note that the SelectionChangeListener is custom class implementing an interface ISelectionChangedListener. A method &#8220;selectionChanged&#8221; will be invoked on the above instance whenever user select control in MXML design editor. The method has one argument of &#8220;SelectionChangedEvent&#8221; which can be used to get the reference of the component selected. I leave the part of getting reference of control using instance of &#8220;SelectionChangedEvent&#8221; to you.<br />
For demonstration, I have created a sample plugin which displays component selected in &#8220;Sample View&#8221;, check below images.<br />
<img src="http://www.carbonrider.com/wp-content/uploads/2010/05/flex_builder_c2.jpg" alt="Flex Builder - Button selected" /></p>
<p><img src="http://www.carbonrider.com/wp-content/uploads/2010/05/flex_builder_c1.jpg" alt="Flex Builder - checkbox selected" /></p>
<p>The story doesnt end here, I would be revealing more details about API &#8211; watch this space.</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2010/05/02/extending-flex-builder-3-building-eclipse-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex Builder 3 &#8211; Plug-in Development</title>
		<link>http://flex.carbonrider.com/2010/04/07/flex-builder-3-plug-in-development/</link>
		<comments>http://flex.carbonrider.com/2010/04/07/flex-builder-3-plug-in-development/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 18:05:09 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[extend flex builder]]></category>
		<category><![CDATA[flex builder 3 plugin]]></category>
		<category><![CDATA[flex builder customization]]></category>
		<category><![CDATA[Flex Builder plugin]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=250</guid>
		<description><![CDATA[One of the best feature (yes there are many more) of Eclipse is extensibility. While it has been a most preferred IDE, not just for the development in Java, but for other languages like PHP, XML, HTML etc. building plugin for eclipse is pretty easy. The readymade wizards and built-in plugin templates makes life easier [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F04%2F07%2Fflex-builder-3-plug-in-development%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2010%2F04%2F07%2Fflex-builder-3-plug-in-development%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the best feature (yes there are many more) of Eclipse is extensibility. While it has been a most preferred IDE, not just for the development in Java, but for other languages like PHP, XML, HTML etc. building plugin for eclipse is pretty easy. The readymade wizards and built-in plugin templates makes life easier of developers. There are many other IDE built on top of eclipse and one amongst them &#8211; Flex Builder (or should I call it Flash Builder &#8211; version 4 has launched in market) is fantastic example of showing what eclipse is capable of.<br />
<span id="more-250"></span><br />
While Eclipse is being so developer friendly with extensions and plethora of information available on how to extend it further, I am somewhat disappointed with Flex Builder extension. Well there are few reasons behind this<br />
1. There is no enough information OR documentation available on internet on how to extend Flex Builder.<br />
2. Though Flex Builder help contains couple of pages documentation about its extensibility features, it doesn&#8217;t seems to be enough and informative for the developers.</p>
<p>I am in the process of extending Flex Builder and after spending few hours in understanding how different editors &#8211; MXML, AS work within Flex Builder, I could able to get some insight of Flex Builder.</p>
<p>It seems I would be spending few more days (or may be weeks) in finding some secrets of FlexBuilder. Keep watching this space and I would publish my research on Flex Builder.</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2010/04/07/flex-builder-3-plug-in-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Item Editor &#8211; Tabbing &#8211; Flex Datagrid</title>
		<link>http://flex.carbonrider.com/2009/12/19/item-editor-tabbing/</link>
		<comments>http://flex.carbonrider.com/2009/12/19/item-editor-tabbing/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 15:30:00 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[custom item editor tabbing]]></category>
		<category><![CDATA[DataGrid Item Editor]]></category>
		<category><![CDATA[DataGrid tabbing]]></category>
		<category><![CDATA[Flex DataGrid]]></category>
		<category><![CDATA[Item Editor tabbing]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=160</guid>
		<description><![CDATA[Most of you, must have customized Flex DataGrid using custom item editors, may be to format an information or to group multiple controls in one column. Customizing appearance of DataGrid cells is one of the powerful feature of Flex and comes to the rescue of developer. This article discusses one of the problem faced by [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2009%2F12%2F19%2Fitem-editor-tabbing%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2009%2F12%2F19%2Fitem-editor-tabbing%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Most of you, must have customized Flex DataGrid using custom item editors, may be to format an information or to group multiple controls in one column. Customizing appearance of DataGrid cells is one of the powerful feature of Flex and comes to the rescue of developer. This article discusses one of the problem faced by the developers while implementing customized item editor.</p>
<p><span id="more-160"></span></p>
<p>Consider an example where in 3 columns are added to DataGrid as<br />
1. Customer ID<br />
2. Customer Name<br />
3. No. of Orders</p>
<p>All of these columns should be editable and a search icon should be placed next to customer name textbox. Users should be able to search customer name by clicking on search icon.</p>
<p>Usually, developers tend to use custom item editor along with HBox or Canvas to achieve this requirement. But there are problems of using HBox or Canvas as a root tag for Item Editor. If your users mostly like to use Keyboard over mouse, you will notice that &#8220;Tab&#8221; do not work as per expectation. Users will find your application keyboard-unfriendly and may get frustrated due to forceful use of mouse. Compile following code and just tab through grids, you will notice the problem.</p>
<pre class="brush: xml;">
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:ArrayCollection id="dgProvider">
		<mx:Array>
			<mx:Object custId="C1191" custName="John Michael" noOfOrder="10"/>
			<mx:Object custId="C2252" custName="Ginny" noOfOrder="5"/>
			<mx:Object custId="C3442" custName="Jeremy" noOfOrder="2"/>
			<mx:Object custId="C5634" custName="Kate" noOfOrder="17"/>
		</mx:Array>
	</mx:ArrayCollection>
<mx:DataGrid dataProvider="{dgProvider}" editable="true" width="550">
		<mx:columns>
			<mx:DataGridColumn dataField="custId" headerText="Customer ID" rendererIsEditor="true" itemRenderer="mx.controls.TextInput"/>
			<mx:DataGridColumn dataField="custName" rendererIsEditor="true" headerText="Customer Name" width="250">
				<mx:itemRenderer>
					<mx:Component>
						<mx:HBox>
							<mx:Script>
							<![CDATA[
								import mx.controls.Alert;
								public function get text():String
								{
									return txtCustName.text;
								}
							]]&gt;
							</mx:Script>
							<mx:TextInput text="{data.custName}" id="txtCustName"/> <mx:Spacer width="15"/>
							<mx:Button click="Alert.show('Display search popup here.')" icon="@Embed('../images/search.gif')" width="15" height="15"/>
						</mx:HBox>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn dataField="noOfOrder" headerText="# of Order" rendererIsEditor="true" itemRenderer="mx.controls.TextInput"/>
		</mx:columns>
	</mx:DataGrid>
</mx:Application>
</pre>
<p>Well does that mean, there is no way to achieve perfect tabbing in DataGrid, aha &#8211; thats not true at all. You can certainly tweak Flex framework and achieve the desired functionality by adding few lines of ActionScript and changing the root tag.</p>
<p>Here is the working version of same.</p>
<pre class="brush: xml;">
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:ArrayCollection id="dgProvider">
		<mx:Array>
			<mx:Object custId="C1191" custName="John Michael" noOfOrder="10"/>
			<mx:Object custId="C2252" custName="Ginny" noOfOrder="5"/>
			<mx:Object custId="C3442" custName="Jeremy" noOfOrder="2"/>
			<mx:Object custId="C5634" custName="Kate" noOfOrder="17"/>
		</mx:Array>
	</mx:ArrayCollection>
<mx:DataGrid dataProvider="{dgProvider}" editable="true" width="550">
		<mx:columns>
			<mx:DataGridColumn dataField="custId" headerText="Customer ID" rendererIsEditor="true" itemRenderer="mx.controls.TextInput"/>
			<mx:DataGridColumn dataField="custName" rendererIsEditor="true" headerText="Customer Name" width="250">
				<mx:itemRenderer>
					<mx:Component>
						<mx:UIComponent keyFocusChange="keyFocusChangeHandler(event)" implements="mx.controls.listClasses.IListItemRenderer, mx.managers.IFocusManagerComponent">
							<mx:Script>
							<![CDATA[
								import mx.controls.Alert;
								import mx.controls.listClasses.BaseListData;

								public function get text():String
								{
									return txtCustName.text;
								}

								override public function setFocus():void
								{
									txtCustName.setFocus();
									txtCustName.drawFocus(true);
								}

								private function keyFocusChangeHandler(event:FocusEvent):void
								{
									if (event.shiftKey)
									{
										if (btnSearch.contains(getFocus()))
										{
											event.preventDefault();
											txtCustName.setFocus();
										}
									}else
									{
										if (txtCustName.contains(getFocus()))
										{
											event.preventDefault();
											btnSearch.setFocus();
										}
									}
								}

								private var _data:Object;

								[Bindable]
								public function get data():Object
								{
									return _data;
								}

								public function set data(value:Object):void
								{
									this._data = value;
								}

								private var _listData:BaseListData;

								public function get listData():BaseListData
								{
									return _listData;
								}

								public function set listData(value:BaseListData):void
								{
									_listData = value;
								}

								override protected function createChildren():void
								{
									super.createChildren();
									addChild(hContainer);
								}

								override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
								{
									hContainer.width = unscaledWidth;
									hContainer.height = unscaledHeight;
								}
							]]&gt;
							</mx:Script>
							<mx:HBox id="hContainer">
								<mx:TextInput text="{data.custName}" id="txtCustName"/> <mx:Spacer width="15"/>
								<mx:Button id="btnSearch" click="Alert.show('Display search popup here.')" icon="@Embed('../images/search.gif')" width="15" height="15"/>
							</mx:HBox>
						</mx:UIComponent>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn dataField="noOfOrder" headerText="# of Order" rendererIsEditor="true" itemRenderer="mx.controls.TextInput"/>
		</mx:columns>
	</mx:DataGrid>
</mx:Application>
</pre>
<p>You will require serach.gif image in order to run this sample program.</p>
<p>Updated: To download above source code, please <a href="http://www.carbonrider.com/wp-content/uploads/2010/09/datagrid-tabbing-src.zip">click here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2009/12/19/item-editor-tabbing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Webservice Session Maintenance &#8211; Apache CXF, Blaze DS, Spring and Flex</title>
		<link>http://flex.carbonrider.com/2009/11/22/apache-cxf-blaze-ds-spring-and-flex/</link>
		<comments>http://flex.carbonrider.com/2009/11/22/apache-cxf-blaze-ds-spring-and-flex/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 13:50:15 +0000</pubDate>
		<dc:creator>Carbon Rider</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[CXF]]></category>
		<category><![CDATA[Flex Session]]></category>
		<category><![CDATA[JAX-WS client session]]></category>
		<category><![CDATA[Session maintenance across webservice client]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.carbonrider.com/?p=157</guid>
		<description><![CDATA[If Flex is dominting RIA world, CXF is dominating SOA world with its feature rich framework. CXF not only makes developers life easy by abstracting many complex task through a set of APIs but also adheres to WS-* standards without a need to having dependency on other frameworks. On an average to develop a webservices [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fflex.carbonrider.com%2F2009%2F11%2F22%2Fapache-cxf-blaze-ds-spring-and-flex%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fflex.carbonrider.com%2F2009%2F11%2F22%2Fapache-cxf-blaze-ds-spring-and-flex%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If Flex is dominting RIA world, CXF is dominating SOA world with its feature rich framework. CXF not only makes developers life easy by abstracting many complex task through a set of APIs but also adheres to WS-* standards without a need to having dependency on other frameworks.</p>
<p><span id="more-157"></span></p>
<p>On an average to develop a webservices using CXF, would hardly require 5 minutes (If developers use Code First Approach). Developer need to declare a business interface, implementation class for same and annotate both these entities with JAX-WS annotation, configure the webeservice and pufff, you are done. You don&#8217;t even need to run Webservices, plug the configuration with built-in web container and you can test Webservices right from your IDE.</p>
<p>Well to explain all the features of CXF, this articles won&#8217;t be enough (I would rather end up writing 1000&#8242;s of pages.). While working on one of the project involving CXF, Blaze DS, Spring and Flex, we faced one problem and that turned out to be worst nightmare. We had created a set of webservices exposed through CXF and deployed with its own WAR file. On the other hand, we had created one more application, holding Flex SWF files, JAX-WS client configured through CXF &#8211; Spring configuration in XML. The clients were injected in Remoting Destination, using SPRING dependency injection feature. Finally the remoting destinations were exposed through SPRING &#8211; Blaze DS integration project.</p>
<p>So far, everything worked well except one problem, each time remoting destination invokes webservice operation, a new session was getting created and hence webservices were not able to maintain state of the Client.</p>
<p>After visiting to various forums and going through the CXF documentation we found that, CXF does provide a way to maintain session and same is explained at</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1741314/jaxwsproxyfactorybean-sharing-http-session">http://stackoverflow.com/questions/1741314/jaxwsproxyfactorybean-sharing-http-session</a> (Check first reply, second reply provided by me for handler does work perfectly.)</li>
<li><a href="http://www.theserverside.com/news/thread.tss?thread_id=40839">http://www.theserverside.com/news/thread.tss?thread_id=40839</a></li>
</ul>
<p>While both the approach are able to maintain session at client side, it requires that the client code should be aware of webservices API. In our case, since JAXWS:Client was injected through SPRING configuration, making beans aware of WS API would break the architecture. Also using both the above discussed approach are having there own problem, first solution will not be suitable if the number of webservices is huge. This means it would require tracking all the webservices in application. Second approach works well for a single webservice, the moment you use another webservice of same application, voilaaa.. you will see a new session is again created.</p>
<p>Well, we didnt had an option but to somehow maintain session between WS-Client and WS. A thought came in my mind to check how CXF maintains session for a single webservice using BindingProvider, I started going through <a title="HTTPConduit" href="http://www.docjar.com/html/api/org/apache/cxf/transport/http/HTTPConduit.java.html" target="_blank">HTTPConduit</a>.</p>
<p>After carefully reading the source code, I realised that if I could able to add Message.PROTOCOL_HEADERS to every webservice context in a generic way, my job is done. Adding Message.PROTOCOL_HEADERS to webservice context, gives developer a chance to play with HTTP headers. I developed a JAX-WS handler and tracked the request/response for every webservice invocation and added a logic to cofigure Message.PROTOCOL_HEADERS. And yippy!!! my webservice clients are now able to maintain session and that too without a need of modifying webservice client.</p>
<p>All I need to do is,</p>
<ol>
<li>Create JAX-WS handler and configure it in SPRING configuration file.</li>
<li>Add handler to Webservice client.</li>
<li>Use BlazeDS API to hold/retrieve reference of WS session cookies and play with Message.PROTOCOL_HEADERS.</li>
</ol>
<p>I like the extension points provided by CXF to accomplish tasks which are not so easily available in other frameworks.</p>
]]></content:encoded>
			<wfw:commentRss>http://flex.carbonrider.com/2009/11/22/apache-cxf-blaze-ds-spring-and-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

