The problem has nothing to do with setting the data.
Anyway, i found the solution. In MXML you can define the following code:
<mx:Repeater id="r" dataProvider="{dataProvider}">
<mx:VBox width="100%">
<mx:Label text="{r.currentItem.name}" />
<mx:Label text="{r.currentItem.author}" />
</mx:VBox>
</mx:Repeater>
While recycling existing instances of that VBox, it calls
executeBindings with the "recursive" parameter set to true, so that also
its children (the labels) update their Bindings.
In my case the VBox contains a Repeater, which again contains more
components. Since its recursive, the outer Repeater updates the content
of the inner Repeaters (and ignores them).
The solution is to forbid recursive calls of executeBindings by
overriding that method in the RepeatedComponent:
<mx:Script>
<![CDATA[
override public function executeBindings(recurse:Boolean =
false):void {
super.executeBindings(false);
}
]]>
</mx:Script>
That way all the outer Repeater can do is update the bindings of its
children.
Thanks anyway ;d
Norbert
--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Use a setter function. Assign the dataProvider of the component's
> repeater in the setter function. If it is so easy to debug the
binding,
> why are you having a problem?
>
>
>
> Tracy
>
>
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED]
On
> Behalf Of nkopcsek
> Sent: Tuesday, January 08, 2008 11:24 AM
> To: [email protected]
> Subject: [flexcoders] Re: Nested Repeaters: Weird Behaviour
>
>
>
> Hi Tracy,
>
> I simplified my original application to be able to concentrate on the
> problem itself.
> Since a VBox doesn't have a dataProvider that name is free for use.
Also
> i'm not that much interested in code beautifing here ;d.
> The setter function is also not really needed because you can debug
with
> ChangeWatchers and it also doesn't work with a fully typed model (as
in
> my original App).
>
> The problem is the following:
>
> * The ArrayCollection fires a collectionChanged Event
> * The Repeater whats to update the view recycling the existing
> elements
> * The Repeater first goes through its children and updates their
> bindings, which again updates the bindings of their children
>
> * The repeater of the RepeaterComponent doesn't do
> anything, but the out repeater manipulates its childen
> * This is the point where everything goes wrong. Somehow
> all children of RepeaterComponent are updated the way to use the
> repeaterIndex of the outer Repeater, and that's the reason why I get
> 11,11,11 instead of 11,12,13
>
> * The Repeater adds the new element
>
>
> --- In [email protected], "Tracy Spratt" tspratt@ wrote:
> >
> > First, don't use the names of existing properties, methods or
classes
> > for your component, or variable names. Specifically "dataProvider"
and
> > "data".
> >
> >
> >
> > Next, use a setter function instead of a public property, so you can
> > debug the values being passed in. Type the setter function as
> > specifically as you can, avoid Object.
> >
> >
> >
> > ________________________________
> >
> > From: [email protected] [mailto:[EMAIL PROTECTED]
> On
> > Behalf Of nkopcsek
> > Sent: Tuesday, January 08, 2008 9:51 AM
> > To: [email protected]
> > Subject: [flexcoders] Nested Repeaters: Weird Behaviour
> >
> >
> >
> > Hi,
> >
> > I got some really strange behaviour with nested repeaters.
> > In this case a repeater is part of a component which is repeated
> itself
> > (let's call this component RepeatedComponent, see below for code).
> > Whenever I add a new item to the dataProvider of the outer repeater
it
> > doesn't add only the new RepeatedComponent but also updates the
> children
> > of the other components in an unintended way.
> >
> > Instead of
> >
> > 1
> > 11 12 13
> > 2
> > 21 22 23
> > 3
> > 31 32 33
> > x
> > x y z
> >
> > I get
> >
> > 1
> > 11 11 11
> > 2
> > 22 22 22
> > 3
> > 33 33 33
> > x
> > x y z
> > .
> >
> > The strange thing is that all the children of Repeater of the
> > RepeatedComponent get the same repeaterIndex as the
RepeatedComponent
> > itself.
> >
> > Thanks in advance for any hints. Any other solution or even a
> workaround
> > would help me.
> >
> >
> > Code:
> >
> > [RepeatedComponent.mxml]
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
> > <mx:Object id="dataProvider"/>
> > <mx:Label text="{dataProvider.label}"/>
> > <mx:Repeater id="r" dataProvider="{dataProvider.data}" width="100%"
> > recycleChildren="true">
> > <mx:Label text="label: {r.currentItem.label}"/>
> > </mx:Repeater>
> > </mx:VBox>
> >
> > [Test.mxml]
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> > layout="absolute" xmlns:local="*">
> > <mx:Script>
> > <![CDATA[
> > import mx.collections.ArrayCollection;
> >
> > [Bindable]
> > private var dataProvider:ArrayCollection = new
> > ArrayCollection([
> > {label:"1", data:new
> > ArrayCollection([{label:"11"},{label:"12"},{label:"13"}])},
> > {label:"2", data:new
> > ArrayCollection([{label:"21"},{label:"22"},{label:"23"}])},
> > {label:"3", data:new
> > ArrayCollection([{label:"31"},{label:"32"},{label:"33"}])}
> > ]);
> >
> > private function addItem():void {
> > dataProvider.addItem({label:"x", data:new
> > ArrayCollection([{label:"x"},{label:"y"},{label:"z"}])});
> > }
> > ]]>
> > </mx:Script>
> > <mx:VBox>
> > <mx:Repeater id="r" dataProvider="{dataProvider}" width="100%"
> > recycleChildren="true">
> > <local:RepeatedComponent dataProvider="{r.currentItem}"/>
> > </mx:Repeater>
> > <mx:Button label="ClickMe" click="addItem()"/>
> > </mx:VBox>
> > </mx:Application>
> >
>