Hi, I've
just seen part of a Flex training video that I think is incorrect or outdated
(beta 3 was being used at the time)
I just want to double-check that this really is the case.
The video says that the code below would *not* take full advantage of data
binding (ie the data will initially appear in the DataGrid, but it will
not stay updated):
<mx:HTTPService id="heroesDataRequest" url="">xml"
/>
<mx:DataGrid dataProvider="{heroesDataRequest.lastResult.superheroes.hero}"
/>
However, I read in the Flex 2 docs that an HTTPService request will, by deault
return an ArrayCollection (makeObjectsBindable is true by default), and I
am using the data binding syntax in the form of the curly braces. Furthermore,
in order to try and test, I used buttons to change the data in the HTTPService's
lastResult object, and the changes do always seem to be reflected in my
DataGrid:
<mx:HTTPService id="heroesDataRequest" url="">xml"
makeObjectsBindable="true" />
<mx:DataGrid dataProvider="{heroesDataRequest.lastResult.superheroes.hero
}" />
<mx:Button label="button 1" click="heroesDataRequest.lastResult.superheroes.hero[0].name
= 'AAA';" />
<mx:Button label="button 2" click="heroesDataRequest.lastResult.superheroes.hero
[0].name = 'BBB';" />
The tutorial goes on to say that to make binding work properly I should use the
HTTPServices 'result' event handler, and assign the data to a bindable
ArrayCollection variable that I create - this is probably my preferred choice
anyway, but I am curious to know whether both ways are equally appropriate.
Can I safely say that data binding is working fully in the first example, or
could there be scenarios in which it will not work but where the alternative
method would? If so, could someone enlighten me? I'm not yet confident of the
best way to check/debug this kind of thing myself.
Cheers,
Neil