<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Another Flex Weirdness/Gotcha</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<lastBuildDate>Mon, 15 Mar 2010 19:34:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jon</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-202541</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Sun, 17 Jan 2010 01:45:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-202541</guid>
		<description>Gotta say thanks for this....was driving me crazy.

ArrayCollection(dataGrid.dataProvider).refresh(); worked perfectly for me.</description>
		<content:encoded><![CDATA[<p>Gotta say thanks for this&#8230;.was driving me crazy.</p>
<p>ArrayCollection(dataGrid.dataProvider).refresh(); worked perfectly for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dylan</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-192268</link>
		<dc:creator>Dylan</dc:creator>
		<pubDate>Wed, 30 Sep 2009 01:16:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-192268</guid>
		<description>I was having a similar problem using a repeater with a custom component that has a nested second repeater.  Repeater A was registering updates to the Bindable object just fine but Repeater B was not updating itself even though the ArrayCollection B it was using as a dataSource had changed. 

I tried invalidating the components housing the repeaters but that did not work.  I finally took a stab at useing the arrayCollection.refresh() and it worked like magic.  Note: everything is [Bindable], it just another one of those quirks.</description>
		<content:encoded><![CDATA[<p>I was having a similar problem using a repeater with a custom component that has a nested second repeater.  Repeater A was registering updates to the Bindable object just fine but Repeater B was not updating itself even though the ArrayCollection B it was using as a dataSource had changed. </p>
<p>I tried invalidating the components housing the repeaters but that did not work.  I finally took a stab at useing the arrayCollection.refresh() and it worked like magic.  Note: everything is [Bindable], it just another one of those quirks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vitaly Sazanovich</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-189227</link>
		<dc:creator>Vitaly Sazanovich</dc:creator>
		<pubDate>Thu, 20 Aug 2009 23:05:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-189227</guid>
		<description>I also had a similar problem. My DataGrid would update its content only when the popup was opened for the first time. I debugged this into a stale reference to the old instance of the DataGrid. I&#039;m using PureMVC and in the constructor of the mediator for the Popup I was registering mediators for canvases within that popup:
facade.registerMediator(new AdPlacesCanvasMediator(settingsTitleWindow.adPlacesCanvas));
Now, the fix was to unregister them in the onClose event:
facade.removeMediator(AdPlacesCanvasMediator.NAME);
Otherwise a new set of mediators would be created with the next popup. Is it a bug of PureMVC? RegisterMediator should take mediator&#039;s name as a parameter and do not create a new instance of the mediator if it is already registered.</description>
		<content:encoded><![CDATA[<p>I also had a similar problem. My DataGrid would update its content only when the popup was opened for the first time. I debugged this into a stale reference to the old instance of the DataGrid. I'm using PureMVC and in the constructor of the mediator for the Popup I was registering mediators for canvases within that popup:<br />
facade.registerMediator(new AdPlacesCanvasMediator(settingsTitleWindow.adPlacesCanvas));<br />
Now, the fix was to unregister them in the onClose event:<br />
facade.removeMediator(AdPlacesCanvasMediator.NAME);<br />
Otherwise a new set of mediators would be created with the next popup. Is it a bug of PureMVC? RegisterMediator should take mediator's name as a parameter and do not create a new instance of the mediator if it is already registered.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Terry</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-187582</link>
		<dc:creator>Terry</dc:creator>
		<pubDate>Wed, 05 Aug 2009 19:12:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-187582</guid>
		<description>I had a similar problem.  In the snippet below dataObjects is an ArrayCollection that was set as my dataProvider on my AdvancedDataGrid.  I could not get updates to refresh until I added the last line.

public function changeData(event:MouseEvent):void {
   var data:Array = dataObjects.getItemAt(2) as Array;
   data[1] = &quot;pmWizard&quot;;
		
   data = dataObjects.getItemAt(1) as Array;
   data[1] = &quot;treeKing&quot;;
   data[4] = 1967;

   ArrayCollection(dataGrid.dataProvider).refresh();
}</description>
		<content:encoded><![CDATA[<p>I had a similar problem.  In the snippet below dataObjects is an ArrayCollection that was set as my dataProvider on my AdvancedDataGrid.  I could not get updates to refresh until I added the last line.</p>
<p>public function changeData(event:MouseEvent):void {<br />
   var data:Array = dataObjects.getItemAt(2) as Array;<br />
   data[1] = "pmWizard";</p>
<p>   data = dataObjects.getItemAt(1) as Array;<br />
   data[1] = "treeKing";<br />
   data[4] = 1967;</p>
<p>   ArrayCollection(dataGrid.dataProvider).refresh();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Garnet</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-111461</link>
		<dc:creator>Garnet</dc:creator>
		<pubDate>Thu, 31 Jul 2008 23:49:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-111461</guid>
		<description>I agree about weirdness. It&#039;s easy to do cool stuff in Flex quickly, but then you run into a quirk that takes way too long to solve. 

I have this as the data provider for my AdvancedDataGrid: 
        private var dpList:ArrayCollection = new ArrayCollection([
              {Ref:true, Name:&quot;Garnet&quot;, 
                  ReadTime:400}]);

In timer routines I want to 
   dpList[0].ReadTime++

But the grid won&#039;t update. I tried all of these, and none of them work to cause an update:
              dpList.refresh();
              adgList.validateNow();
              adgList.executeBindings(false);
 
The one thing that does work is doing 
              dpList.addItem(...)

Guess I need to trace into the source for addItem and figure out what it is doing.</description>
		<content:encoded><![CDATA[<p>I agree about weirdness. It's easy to do cool stuff in Flex quickly, but then you run into a quirk that takes way too long to solve. </p>
<p>I have this as the data provider for my AdvancedDataGrid:<br />
        private var dpList:ArrayCollection = new ArrayCollection([<br />
              {Ref:true, Name:"Garnet",<br />
                  ReadTime:400}]);</p>
<p>In timer routines I want to<br />
   dpList[0].ReadTime++</p>
<p>But the grid won't update. I tried all of these, and none of them work to cause an update:<br />
              dpList.refresh();<br />
              adgList.validateNow();<br />
              adgList.executeBindings(false);</p>
<p>The one thing that does work is doing<br />
              dpList.addItem(&#8230;)</p>
<p>Guess I need to trace into the source for addItem and figure out what it is doing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Henry</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-70915</link>
		<dc:creator>William Henry</dc:creator>
		<pubDate>Thu, 03 Apr 2008 23:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-70915</guid>
		<description>You can use myDataGrid.executeBindings(false);
The argument determines whether there is recursion.</description>
		<content:encoded><![CDATA[<p>You can use myDataGrid.executeBindings(false);<br />
The argument determines whether there is recursion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barneyb</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-22227</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Sun, 24 Jun 2007 16:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22227</guid>
		<description>Thanks for the comments.  I&#039;m aware of how to make it work, I&#039;m just surprised it doesn&#039;t work by default.  I.e. there aren&#039;t per-property watchers, just per-object watchers.  Refreshing the provider, reexecuting bindings, putting ChangeWatchers on the properties manually, etc., would al work, but it just seems weird to have to do that manually.

I haven&#039;t tried it, but I&#039;d be willing to bet that a custom itemRenderer that manually binds itself to the specific property (but is otherwise a &quot;normal&quot; renderer) would fix the issue.  Then you could just use that in all your DataGrids and have it taken care of &quot;automatically&quot;.</description>
		<content:encoded><![CDATA[<p>Thanks for the comments.  I'm aware of how to make it work, I'm just surprised it doesn't work by default.  I.e. there aren't per-property watchers, just per-object watchers.  Refreshing the provider, reexecuting bindings, putting ChangeWatchers on the properties manually, etc., would al work, but it just seems weird to have to do that manually.</p>
<p>I haven't tried it, but I'd be willing to bet that a custom itemRenderer that manually binds itself to the specific property (but is otherwise a "normal" renderer) would fix the issue.  Then you could just use that in all your DataGrids and have it taken care of "automatically".</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JesterXL</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-22222</link>
		<dc:creator>JesterXL</dc:creator>
		<pubDate>Sun, 24 Jun 2007 15:28:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22222</guid>
		<description>You have a lot more options.

1.

[Bindable]
PersonVO
{
   public var firstName:String;
   public var lastName:String;
   public var address:AddressVO;
}

Using an ArrayCollection that&#039;s full of PersonVO&#039;s, your DataGrid would have each column bound to 1 of the properties.  In this case, it&#039;s assumed that your AddressVO has a toString() method to return a nicely formatted Address string.

2. Use a label function.  When a variable changes on your VO, your label function will run and you can format it how you wish.

3. Use an itemRenderer.  While it&#039;s implied you are building the itemRenderer per column, you basically get your data function which is fed the object from the ArrayCollection, so you don&#039;t necessarely have to use the column name in question.

In all scenarios above, if you change the &quot;firstName&quot; property, the field will update in the DataGrid (whether on its own, via your labelFunction getting called again, or your itemRenderer&#039;s data setter getting run).  If it&#039;s not, you are either not using the Bindable tag up top, or not strongly typing your variables.</description>
		<content:encoded><![CDATA[<p>You have a lot more options.</p>
<p>1.</p>
<p>[Bindable]<br />
PersonVO<br />
{<br />
   public var firstName:String;<br />
   public var lastName:String;<br />
   public var address:AddressVO;<br />
}</p>
<p>Using an ArrayCollection that's full of PersonVO's, your DataGrid would have each column bound to 1 of the properties.  In this case, it's assumed that your AddressVO has a toString() method to return a nicely formatted Address string.</p>
<p>2. Use a label function.  When a variable changes on your VO, your label function will run and you can format it how you wish.</p>
<p>3. Use an itemRenderer.  While it's implied you are building the itemRenderer per column, you basically get your data function which is fed the object from the ArrayCollection, so you don't necessarely have to use the column name in question.</p>
<p>In all scenarios above, if you change the "firstName" property, the field will update in the DataGrid (whether on its own, via your labelFunction getting called again, or your itemRenderer's data setter getting run).  If it's not, you are either not using the Bindable tag up top, or not strongly typing your variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Ellis</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-22142</link>
		<dc:creator>Brandon Ellis</dc:creator>
		<pubDate>Sun, 24 Jun 2007 03:13:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22142</guid>
		<description>Hi,
Instead of sorting the rows, you should be able to call ArrayCollection.refresh(); and that will trigger an update.

I&#039;m doing that in an app of mine. :)</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Instead of sorting the rows, you should be able to call ArrayCollection.refresh(); and that will trigger an update.</p>
<p>I'm doing that in an app of mine. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaun</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/comment-page-1/#comment-22131</link>
		<dc:creator>shaun</dc:creator>
		<pubDate>Sun, 24 Jun 2007 01:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22131</guid>
		<description>I think I call grid.dataProvider.refresh from a custom event handler when i&#039;ve completed updating the dataprovider.

HTH</description>
		<content:encoded><![CDATA[<p>I think I call grid.dataProvider.refresh from a custom event handler when i've completed updating the dataprovider.</p>
<p>HTH</p>
]]></content:encoded>
	</item>
</channel>
</rss>
