I see duplicate dataprovider entries which might confuse which selectedIndex to 
use.

They key is to make sure binding events are getting dispatched.  You might want 
to add a logging facility to track changes and events and some other properties.


On 3/21/12 8:09 AM, "Uber_Nick" <nic...@gmail.com> wrote:






It's been happening with all configurations, but intermittently.  I've had 0 
success reproducing it at will, even though myself and multiple users have come 
across it on non-dev environments.

My troubleshooting has mostly been releasing things I think *might* have an 
impact, then asking users to send screen caps if they come across the issue 
again.  It seems to be occurring regularly, although a hundred runs of the code 
below haven't shown it on my dev box.  So I can't tell if there are any console 
messages at runtime.  There are no compile-time warnings, and there weren't any 
of these issues when compiling with Flex 3 (swapping Spark components for Halo).

Below is an 80-line, 4-file example I've been trying to use to attempt to 
reproduce the problem.  I have not been successful reproducing it, but the 
structure and components used below closely resembled the full app.  Only thing 
missing is that the full app has a set of Mate controllers and a bunch of AMF 
remote calls.  Nothing those touch seem to be affected though.

Since this problem is so hard to reproduce, I don't expect a resolution here.  
Just seeing if I'm doing something glaringly wrong or if the problems sound 
familiar to other developers.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" 
xmlns:local="*"
>

<fx:Declarations>
<local:MyModel id="model" />
</fx:Declarations>

<mx:ViewStack selectedIndex="{model.viewStackIndex}">
<s:NavigatorContent
showEffect="Fade"
hideEffect="Fade"
>
<local:Page1 model="{model}" />
</s:NavigatorContent>
<s:NavigatorContent
showEffect="Fade"
hideEffect="Fade"
>
<local:Page2 model="{model}"/>
</s:NavigatorContent>
</mx:ViewStack>
</s:Application>

// MyModel.as
package
{
[Bindable]
public class MyModel
{
public var viewStackIndex:Number=0;

public var one:String="one";
public var two:String="two";
public var three:String="three";
public var four:String="four";
}
}

// Page1.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009";
 xmlns:s="library://ns.adobe.com/flex/spark"
 xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" 
xmlns:local="*">
<fx:Declarations>
<local:MyModel id="model" />
</fx:Declarations>
<s:Button label="Forward" x="150" y="100" click="model.viewStackIndex = 
(model.viewStackIndex == 0) ? 1 : 0;"/>
</s:Group>

// Page2.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009";
 xmlns:s="library://ns.adobe.com/flex/spark"
 xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300" 
xmlns:local="*"
 >
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
]]>
</fx:Script>

<fx:Declarations>
<local:MyModel id="model" />
</fx:Declarations>
<s:TextInput x="10" y="10" text="{model.one}" />
<s:CheckBox x="250" y="10" label="{model.two}" selected="{model.two=='two'}" 
visible="{model.two=='two'}" />
<s:Button label="Back" x="150" y="100" click="model.viewStackIndex = 
(model.viewStackIndex == 0) ? 1 : 0;"/>
<s:Label x="10" y="200" text="{model.three}" />
<s:DropDownList x="250" y="200"  selectedItem="{model.four}" dataProvider="{new 
ArrayList(['bar', 'four', 'bar', 'bar', 'bar', 'bar'])}" />
</s:Group>

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , Alex 
Harui <aharui@...> wrote:
>
> So is this intermittent or just never works in this configuration?  Are there 
> console warning about not being able to detect changes?
>
> Can you make a 20-line test case?
>
>
> On 3/20/12 7:05 PM, "Uber_Nick" <nick14@...> wrote:
>
>
>
>
>
>
> Nope, no difference with one vs two-way Bindings.  I discovered this problem 
> with DropDownLists that had one-way bindings and used the change event to 
> update the value vo.  I may have even been using selectedIndex instead of 
> selectedItem-- don't remember.
>
> The problem persisted after I tried two-way bindings.
>
> Funny thing about it would be that the DropDownList would say "May" but the 
> value of the VO would still be "February".  I'd then change the DropDownList 
> to "June" and the VO would update to "June".  So the pointers were all 
> referencing the right objects.
>
> Even stranger-- changing the VO again externally would not update the 
> DropDownList.  Something was going on with either the binding inside the 
> DropDownList or the display/render function.  I would have blamed that 
> component if it weren't also happening on Input Boxes.
>
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>  
> <mailto:flexcoders%40yahoogroups.com> , Alex Harui <aharui@> wrote:
> >
> > If you take off the two-way binding does it work?
> >
> >
> > On 3/18/12 7:41 PM, "Uber_Nick" <nick14@> wrote:
> >
> >
> >
> >
> >
> >
> > I haven't tried explicitly re-setting the value manually or with 
> > BindingUtils, but that's something I'll try now!  Should still be working 
> > without that.
> >
> > I have a feeling the problem is actually in the display logic of the 
> > component.  Like perhaps some built-in efficiency code to ignore binding 
> > updates when it's hidden.  But I'll have to deep-dive a little further to 
> > verify that.  It's more likely something I'm missing or doing wrong.
> >
> > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>  
> > <mailto:flexcoders%40yahoogroups.com>  
> > <mailto:flexcoders%40yahoogroups.com> , yang chen <chenyang3@> wrote:
> > >
> > > Have you tried using binding util?
> > >
> > > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>  
> > > > <mailto:flexcoders%40yahoogroups.com>  
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > From: nick14@
> > > > Date: Fri, 16 Mar 2012 20:08:47 +0000
> > > > Subject: [flexcoders] Bindings on visual components being forgotten?  
> > > > (Flex 3 -> 4.6)
> > > >
> > > > Seeing a strange, rare, issue after updating an app to 4.6.  I can't 
> > > > seem to reproduce it in a dev environment, so I'll list out my issue 
> > > > and setup to see if it sounds familiar to anyone.
> > > >
> > > > The problem:
> > > > Visual components seem to occasionally "forget" the objects they're 
> > > > bound to.  For instance, I have something like this:
> > > >
> > > > <s:DropDownList
> > > >     id="cmbMonth"
> > > >     dataProvider="{model.months}"
> > > >     selectedItem="@{model.selectedMonth}"
> > > > />
> > > > <s:Label text="{model.selectedMonth}" />
> > > >
> > > > When the problem occurs, the "selectedMonth" in the label component is 
> > > > correct, say, February.  But the DropDownList will display a blank.  
> > > > Even though the DropDownList contains all the months, meaning 
> > > > models.months is bound correctly.
> > > >
> > > > I tried adding:
> > > >     requireSelection="true"
> > > >
> > > > The addition changed the behavior.  No more blanks!  But now, instead 
> > > > of blanks, selectedMonth is showing something random like "May".
> > > >
> > > > Background:
> > > > App has been in production in various versions of Flex 3 for two years 
> > > > without ever seeing this.  Upgrading to Flex 4 and swapping out some 
> > > > Halo components with equivalent Spark ones, users, myself included, 
> > > > began noticing this phenomenon.  I cannot seem to reproduce it in a 
> > > > reliable fashion.  But I've gotten some feedback based on some 
> > > > attempted fixes pushed out to users.
> > > >
> > > > Troubleshooting so far:
> > > > Since it normally works, there's no super-obvious things missing, like 
> > > > an uninitialized pointer, missing "Bindable" tag, accidental = 
> > > > assignment instead of == comparison, etc.
> > > >
> > > > Also, we know the variable references are pointing to the correct 
> > > > place.  model.selectedMonth is showing up fine for a label just 
> > > > underneath the dropdown.  model.months is being referenced just fine by 
> > > > the dropdown itself.  It's just the display of model.selectedMonth in 
> > > > the dropdown.  Upon saving, the model.month property correctly 
> > > > propagates itself to the DB, even when the dropdown is displaying the 
> > > > wrong value.  Switching between one-way and two-way bindings don't seem 
> > > > to make a difference either.  I noted above that I tried forcing 
> > > > requireSelection="true", which does prevent the DropDownList from being 
> > > > blanked-out, but doesn't force it to stay on the correct value.
> > > >
> > > > I thought it might be related to just the DropDownList component, but 
> > > > the problem is also occurring on s:TextInput's text property.  Seems 
> > > > like when it happens with the TextInput component (showing a blank 
> > > > value), it's doing so for all the TextInput components.  I'm not so 
> > > > sure if it's happening for all DropDownList elements, though.
> > > >
> > > >
> > > > App setup:
> > > > I have an mx:ViewStack attached to hide/show effects with two 
> > > > containers inside (loggedOff/loggedOn), and a TabNavigator within that. 
> > > >  I think the problems are only occurring after switching between states 
> > > > for the ViewStack.  So after the components are hidden and come back.  
> > > > I remembered back to the Flex 2 ViewStack issue where bindings didn't 
> > > > refresh, and added the old workaround to my code:
> > > >     change="executeBindings(true)"
> > > >
> > > > This didn't fix it.  Anything else I can look at or try?  Anyone else 
> > > > experience this before?  Any chance it's related to the framework 
> > > > instead of my code?
> > > >
> > > >
> > > >
> > > > ------------------------------------
> > > >
> > > > --
> > > > Flexcoders Mailing List
> > > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > > Alternative FAQ location: 
> > > > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> > > > Search Archives: 
> > > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups 
> > > > Links
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
> >
> >
> > --
> > Alex Harui
> > Flex SDK Team
> > Adobe Systems, Inc.
> > http://blogs.adobe.com/aharui
> >
>
>
>
>
>
>
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>






--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui

Reply via email to