6 Replies Latest reply on Nov 23, 2008 11:56 PM by SujitG

    titleWindow nightmare

    AlexAAM Level 1
      Hello to all, i want to make a question that is drive me crazy. i am relatively new to flex. and i have a program that shows a titleWindow based component, using popupManager. In the titleWindow's creationComplete event i call a function named init, that makes a netconnection call to the server. the server is responding with the data and returns an ArrayCollection that is binded to a combo box in the client. this data are received in a result handler event of the titleWindow. The problem is:
      if i run the program and if i enter to the this screen a first time it load the data ok (i watch this with the flex builder debugger), and the data are loading ok inside the ArrayCollection binded to the combo box, but the combo don't show the data (it don´t refresh itself).
      If i enter a second time to the screen then the data are loaded againg from the server and now it appears on the screen.
      evidently this is a problem of refresh the screen. and i have a week looking for a solution. i try using creationPolicy='all', change the creationComplete='init();' for another event on the titleWindow, and many other things but nothing seems work.

      Thanks in advance
        • 1. Re: titleWindow nightmare
          Level 7

          "AlexAAM" <webforumsuser@macromedia.com> wrote in message
          news:gg42b9$k17$1@forums.macromedia.com...
          > Hello to all, i want to make a question that is drive me
          > crazy. i
          > am relatively new to flex. and i have a program that shows a titleWindow
          > based
          > component, using popupManager. In the titleWindow's creationComplete event
          > i
          > call a function named init, that makes a netconnection call to the
          > server. the
          > server is responding with the data and returns an ArrayCollection that is
          > binded to a combo box in the client. this data are received in a result
          > handler
          > event of the titleWindow. The problem is:
          > if i run the program and if i enter to the this screen a first time it
          > load
          > the data ok (i watch this with the flex builder debugger), and the data
          > are
          > loading ok inside the ArrayCollection binded to the combo box, but the
          > combo
          > don't show the data (it don?t refresh itself).
          > If i enter a second time to the screen then the data are loaded againg
          > from
          > the server and now it appears on the screen.
          > evidently this is a problem of refresh the screen. and i have a week
          > looking
          > for a solution. i try using creationPolicy='all', change the
          > creationComplete='init();' for another event on the titleWindow, and many
          > other things but nothing seems work.

          It looks like the formatting got hosed when you posted this. I have a
          really hard time parsing long blocks of solid text. Maybe if you tried
          again and added extra space in between your paragraphs, I'd have an easier
          time being able to help you.


          • 2. Re: titleWindow nightmare
            AlexAAM Level 1
            Hello to all, i want to make a question that is drive me crazy:

            i am relatively new to flex. and i have a program that shows a titleWindow based component, using popupManager. In the titleWindow's creationComplete event i call a function named init, that makes a netconnection call to the server. the server is responding with the data and returns an ArrayCollection that is binded to a combo box in the popup window (the titleWindow). this data are received in a result handler event of the titleWindow. The problem is:


            if i run the program and when i enter to the screen a first time it load the data ok (i watch this with the flex builder debugger), and the data are loading ok inside the ArrayCollection binded to the combo box, but the combo box don't show the data (it don´t refresh itself).


            If i enter a second time to the popup window, then the data are loaded again from the server and now it appears on the combo.


            evidently this is a problem of screen refresh , and i have a week looking for a solution. i try using creationPolicy='all', i try changing the creationComplete='init();' for another event on the titleWindow, and many other things but nothing seems work.

            Thanks in advance
            • 3. Re: titleWindow nightmare
              Mitek17 Level 1
              Hi Alex,

              Welcome to the World of Nightmares with COMBOBOX! :)

              Have a read in blog about ComboBox problems and how to overcome it:
              http://mitek.id.au/blog/2008/10/28/combobox-madness-continues/
              http://mitek.id.au/blog/2008/08/18/combobox-selecteditem-problem/
              http://mitek.id.au/blog/2008/06/09/unselect-in-combobox/

              PS I am still wondering how come in the event-driven environment FlexSDK is so certain about handling the events in particular order.

              Cheers,
              Dmitri.
              • 4. Re: titleWindow nightmare
                SujitG Level 2
                Hi,

                Is your ArrayCollection marked as Bindable? Can you please share the code.

                Hope this helps.
                • 5. Re: titleWindow nightmare
                  AlexAAM Level 1
                  Hello, my arrayCollection is marked Bindable: this is the code:

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="448"
                  height="498" showCloseButton="true" title="Imagen" borderThicknessBottom="3"
                  borderThicknessLeft="3" borderThicknessRight="3" borderThicknessTop="-5"
                  close="cerrar_ventana();" xmlns:ns1="*" creationComplete="init();" visible="true" >
                  <mx:Label x="43" y="133" text="Imagen" width="79"/>
                  <mx:ComboBox id="cimagen" x="105" y="130" width="248" height="20" rowCount="15"
                  change="procesar_imagen(cprev.selected)" dataProvider="{cimagen_data}" />

                  <mx:Script>
                  <![CDATA[
                  import mx.events.CollectionEventKind;
                  import mx.binding.utils.BindingUtils;
                  import mx.utils.ObjectUtil;
                  import mx.utils.UIDUtil;
                  import mx.collections.ArrayCollection;
                  import mx.core.*;
                  import mx.controls.Alert;
                  import mx.managers.PopUpManager;

                  [Bindable]
                  public var cimagen_data:ArrayCollection=new ArrayCollection();

                  private function init():void
                  {

                  // preparamos la ventana
                  //cimagen_data.push({label:'[none]',data:''});
                  cimagen_data.addItem({label:'[none]',data:''});
                  cimagen.selectedIndex=0;

                  var n:NetConnection=Application.application.netConnect;
                  if (n!=null)
                  n.call("WebServPortalFlex.servicios.obtenerRecursosUsuario",new Responder(result_obtenerImagenesUsuario,null),Application.application.modulo_pageDesigner .gUsernameOwner,1);

                  }


                  private function result_obtenerImagenesUsuario(res:Object):void
                  {

                  var result:Object=res.Table.serverInfo;
                  if (result.initialData[0][0]!="0" && result.initialData[0][0]!="1") // primera fila, primera columna (cod)
                  {
                  Alert.show(result.initialData[0][1]); // primera fila, segunda columna (men)
                  return;
                  }
                  // cargamos el combo imagenes con los datos (label y data)
                  if (result.initialData[0][0]=="0")
                  {
                  // este usuario tiene recursos (imagenes)
                  for (var i:Number = 0;i < result.initialData.length;i++)
                  {
                  var new_item:Object = new Object();
                  new_item.label=result.initialData [3]; // nombreArchivo
                  new_item.data=result.initialData
                  [5]; // rutaFlex
                  cimagen_data.addItem(new_item);

                  //cimagen_data.push(new_item);
                  //cimagen_data.sortOn("label",Array.CASEINSENSITIVE); // ordenamos el array por el campo label
                  }
                  //cimagen.dataProvider=cimagen_data;
                  //cimagen.invalidateDisplayList();

                  }

                  //this.visible=true;
                  cimagen_data.addItem({label:'the end',data:''});


                  }

                  </mx:TitleWindow>

                  well, some important points:
                  - the program show this component like a popup window, using the follow methods in the Application file:
                  var vp:VisualPicture=null;
                  vp= VisualPicture(PopUpManager.createPopUp(this,VisualPicture,true));
                  PopUpManager.centerPopUp(vp);

                  - the server send to flex a .net DataSet object, so the function result_obtenerImagenesUsuario get this data and transform it into arrayCollection. this work fine because i watch it with the flex builder debugger.
                  - it seems this is a databinding problem, because i try binding the cimagen_data arrayCollection to a list, and i get the same problem.
                  - like you could watch i add a last item to the combo labeled 'the end' (after all the data from the server are in the arrayCollection). this item appears in the combo.so for a strange reason the databinding dont work with the data from the server.¿ could be the way i am creating the object that i add to the arrayCollection ?

                  any help will be very much appreciated.

                  • 6. Re: titleWindow nightmare
                    SujitG Level 2
                    Hi,

                    I couldn't replicate the server call, but i tried out adding random data to the ArrayCollection. I could see the data being modified in the ArrayCollection. Can you please check if the execution is entering the for loop.

                    Hope this helps.