I've developed a test mxml file of the current "combobox note updating"
problem at hand.

In the following example, click Fill Data.  The combobox's data fills
up.  Choose either the first or second item in the combobox.  Now click
the associated "Rename Data" button for the item chosen.

Notice that nothing happens?  But wait, if you click the combobox to
open it, you'll see that the data was in fact updated, but we're just
not seeing it.

Now change the ComboBox to a DataGrid.  Everything works fine.

What gives?
  - Chris

PS - you're probably wondering why I used ObjectProxy.  This was because
I noticed in my debugger that everything else was as well for the
particular place where I was testing this.  Regardless, it doesn't seem
to matter what I used (Array, Object, etc.), as the problem still
occurs.

-------------testProblem.mxml-------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="vertical">

  <mx:Script>
   <![CDATA[
    import mx.utils.ObjectProxy;
    import mx.collections.ArrayCollection;

    [Bindable]
    private var ac:ArrayCollection = new ArrayCollection;

    private function init():void {
     var buildData1:ObjectProxy = new ObjectProxy;
     buildData1.field1 = "object1-field1";
     buildData1.field2 = "object1-field2";
     buildData1.field3 = "object1-field3";
     var buildData2:ObjectProxy = new ObjectProxy;
     buildData2.field1 = "object2-field1";
     buildData2.field2 = "object2-field2";
     buildData2.field3 = "object2-field3";
     ac.addItem(buildData1);
     ac.addItem(buildData2);
    }
    private function setFirstItem():void {
     var buildData1_renamed:ObjectProxy = new ObjectProxy;
     buildData1_renamed.field1 = "object1_renamed-field1";
     buildData1_renamed.field2 = "object1_renamed-field2";
     buildData1_renamed.field3 = "object1_renamed-field3";
     ac.setItemAt(buildData1_renamed,cbTestData.selectedIndex);
    }
    private function setSecondItem():void {
     var buildData2_renamed:ObjectProxy = new ObjectProxy;
     buildData2_renamed.field1 = "object2_renamed-field1";
     buildData2_renamed.field2 = "object2_renamed-field2";
     buildData2_renamed.field3 = "object2_renamed-field3";
     ac.setItemAt(buildData2_renamed,cbTestData.selectedIndex);
    }
   ]]>
  </mx:Script>

  <mx:ComboBox id="cbTestData" dataProvider="{ac}" labelField="field1"
width="50%"/>
  <mx:Button label="Fill with Data" click="init()"/>
  <mx:Button label="Rename Data in Item #1 (select the first item before
clicking)" click="setFirstItem()"/>
  <mx:Button label="Rename Data in Item #2 (select the second item before
clicking)" click="setSecondItem()"/>
  <mx:Text text="{cbTestData.selectedItem.field1}"/>
  <mx:Text text="{cbTestData.selectedItem.field2}"/>
  <mx:Text text="{cbTestData.selectedItem.field3}"/>
</mx:Application>



--- In flexcoders@yahoogroups.com, "qnotemedia" <[EMAIL PROTECTED]> wrote:
>
> Concerning this last post - I even changed the combobox to a
> datagrid, nothing else changed, and it works perfectly fine.
>
> What gives? What's so different about the two?
>
> - Chris
>
> --- In flexcoders@yahoogroups.com, "qnotemedia" qnotemedia@
> wrote:
> >
> > I hear ya Tracy. Been browsing it from my MAX docs, and maybe
> we'll
> > do it in the next project. ;)
> >
> > Still harping on this particular thing, I've run into a weird
> > unrelated snag. When the object in the main app is a combobox
> > instead of a datagrid, the combobox's display doesn't update (even
> > tho the data is).
> >
> > i.e. running the titlewindow as an "editor," I edit some values in
> > text boxes from, and when I click "OK" from the titlewindow, the
> AC's
> > are updated with setItemAt and the window closes and the object on
> > the main app updates (because its bound to a public AC variable).
> >
> > If the object is a datagrid, everything updates fine. If its a
> > combobox, it updates the data correctly, but initially it doesn't
> > look like it - the displayed label hasn't changed. Clicking the
> > combobox to open it, you can see that the selected label and data
> are
> > in fact updated. Closing the combobox without choosing anything
> > updates he label correctly. How come its not immediately updated
> > when the AC is, like the datagrid?
> >
> > Tried refresh() on the AC just before closing the window, but that
> > didn't seem to do anything. Not sure what else to try!
> >
> > Thanks all,
> > - Chris
> >
> >
> > --- In flexcoders@yahoogroups.com, "Tracy Spratt" <tspratt@> wrote:
> > >
> > > I am slowly becoming comfortable with using event driven
> > functionality,
> > > so this opinion is only that.
> > >
> > >
> > >
> > > However, the primary benefit of "loose coupling" is re-usability,
> > and
> > > maybe "maintainability", in the sense that it will be easier to
> > drop-in
> > > replacement parts. (any others, anyone?). But event code is a
> > little
> > > harder to write read and debug than straight calls to directly
> > > referenced members. If you are reasonably sure what you are
> > building
> > > will not need to be re-used, then there may be little benefit in
> the
> > > effort to gain loose coupling.
> > >
> > >
> > >
> > > So "wrong"? No. "Best practice"? It depends. Think ahead.
> > >
> > >
> > >
> > > Tracy
> > >
> > >
> > >
> > > ________________________________
> > >
> > > From: flexcoders@yahoogroups.com
> > [mailto:[EMAIL PROTECTED] On
> > > Behalf Of qnotemedia
> > > Sent: Tuesday, December 05, 2006 12:19 PM
> > > To: flexcoders@yahoogroups.com
> > > Subject: [flexcoders] Re: TitleWindow Component...help!
> > >
> > >
> > >
> > > Well - what I've done, after finding a titlewindow example on
> > cflex,
> > > is create a public variable in the titlewindow component of the
> > same
> > > name as one in the application, and I send it to the component
> from
> > > the main app AND back via the title window's instance variable.
> > i.e.:
> > >
> > > TitleWindow Component:
> > >
> > > [Bindable]
> > > public var aListOfData:ArrayCollection;
> > >
> > > private function sendData():void {
> > > -> runs when you click submit in titlewindow
> > > var compilation:Obect = new Object;
> > > compilation.setting1 = "something in component";
> > > aListOfData.addItem(compilation); (or setItemAt, etc)
> > > }
> > >
> > > Main Application looks like this:
> > >
> > > [Bindable]
> > > private var aListofData:ArrayCollection;
> > >
> > > private function openComponent():void {
> > > -> runs when you click open window in the main app
> > > var openingWindow....blah blah, opening the TitleWindow;
> > > openingWindow.aListOfData = aListOfData;
> > > }
> > >
> > > OK - so those variable names are random thoughts off the top of
> my
> > > head, bu you get the picture. From what I understand, this
> doesn't
> > > follow the idea behind "loosely coupled components," but is there
> > > anything really "wrong" with this methodology? It seems to work
> > very
> > > well in my case. I can even have a window within a window, all
> > > passing variables between windows, all the way down to the main
> app
> > > quite easily, and so far its been a breeze to setup.
> > >
> > > Thoughts anyone? If I continue down this path, where will I start
> > to
> > > run into problems?
> > > - Chris
> > >
> > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%
> > 40yahoogroups.com>
> > > , "Roman Protsiuk"
> > > <roman.protsiuk@> wrote:
> > > >
> > > > Hi.
> > > >
> > > > Why don't your pop up dispatch some event (e.g. "submitData")
> and
> > > you listen
> > > > to it?
> > > >
> > > > R.
> > > >
> > > > On 12/5/06, qnotemedia <qnotemedia@> wrote:
> > > > >
> > > > > OK - so I'm using the generic TileWindow example found on the
> > > > > Component Explorer. It basically shows you how to build
> > something
> > > > > where:
> > > > > 1) User clicks a button, Window pops up.
> > > > > 2) User types into a text box in the window, clicks Submit.
> > > > > 3) Text typed in appears in the main app.
> > > > >
> > > > >
> > >
> http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html
> > >
> >
> <http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html>
> >
> > > > >
> > > > > But, I'm having a little difficulty understanding the
> > assignment
> > > of
> > > > > the returned data. i.e.:
> > > > >
> > > > > login.loginName=returnedName;
> > > > >
> > > > > ...where login is the instance of the TitleWindow, loginName
> is
> > a
> > > > > public Text variable inside the component, and returnedName
> is
> > a
> > > text
> > > > > box in the main app.
> > > > >
> > > > > My confusion comes up when I try to edit this so that:
> > > > > 1) App has a combobox. Dataprovider for the combobox is an
> > > > > ArrayCollection of data: "data" and "label." User clicks a
> > button,
> > > > > TitleWindow pops up.
> > > > > 2) User types into a text box in the window, clicks Submit.
> > > > > 3) The text is a passed as a label, along with a generated ID
> > > > > (generated in the component) and is added to the combobox's
> > > > > dataprovider.
> > > > >
> > > > > The problem appears to be that there is no handler of the
> Submit
> > > > > button click on the main application. Obviously, I would add
> to
> > a
> > > > > datasource and return an ID from that, but I can't even get
> > this
> > > to
> > > > > work manually (i.e. for testing purposes, setting a static
> data
> > > and
> > > > > label).
> > > > >
> > > > > Just trying to keep this as simple as possible. Seems to me
> > that
> > > if
> > > > > I can pass a string of text, I should also be able to pass an
> > > Object
> > > > > that is added to a dataProvider in the main app? Right?
> > > > >
> > > > > Help!
> > > > > - Chris
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>


Reply via email to