4 Replies Latest reply on Oct 26, 2010 10:03 PM by satyasuppu

    In Flex application functionality is working sometimes and not working sometimes..

    satyasuppu Level 1

      Hi,

       

      Please help me on this..

       

      In my flex application some functionality is working some times and not working sometimes..

       

      In my project i have 5 sections with 5 separate screens..Each screen is of one diffeent module.

       

      After logining into the application:

       

        I will go to one screen..First time every functionality is working in that screen..

       

      Ex:: I have a screen with datagrid.From that user will select one job name from datagrid click on next button..

      Based the job name the user selected i have to display some information in next screen and customer names.customer names is a combo box..

       

      below is the code:::

       

                     public function populateAllOEMCustomers(event:ResultEvent):void
                  {

       

                1)     var object_CustomerList:CustomerList = event.result as CustomerList; //Assigining result object values to Object reference variable.
                 
                2)    var allOEMCustomersCollection:ArrayCollection = new ArrayCollection(); //Declaration ArrayColliction referance variable.
                     

               3)       var i:int=0;
               4)      var customerComboLabel:Label = new Label();
                     
                5)      for (i = 0;i < object_CustomerList.arryCollCustName.length; i++)
                      {                       
                          var strCustName:String = object_CustomerList.arryCollCustName.getItemAt(i).toString();
                          var strCustId:String = object_CustomerList.arryCollCustId.getItemAt(i).toString();
                         
                          customerComboLabel = new Label(); //Dynamic declaration of label.
                         
                          customerComboLabel.name = strCustName; //Assinging the customer name to the Label name field.
                          customerComboLabel.text = strCustId; //Assingning the customer id to the Label text field.
                         
                          allOEMCustomersCollection.addItem(customerComboLabel); //Adding Lable into the ArrayCollection referace variable.                                       
                      }
                      //customerComboID.selectedItem = "--";   
                      OEMCustomersComboID.dataProvider = allOEMCustomersCollection;
                      OEMCustomersComboID.selectedItem = -1;

      }

       

      This functionality is working fine when i visit to this screen first time..If you go back to another screen and come back to this same screen and click on next button this time customer names combo box has no customer details..I am getting Nullpointer Exception and it is showing the line number 5( i have given the number for code given above..)

       

      If i change the first line of the code to below code:: every time the above functionality is working fine.Not getting any error msg..

       

        var object_CustomerList:Object= event.result ;

       

       

       

      If i  type cast it to specific class(CustomerList) ,functionality is not working ..getting null pointer exception..If i type cast it to Object everything is working fine..In my code wherever i have typecasted it to specific class functionality is not working(gettingNullpointerExcepion).

       

      Please help me on this..I am not getting what could be the reason..

       

      I am using::Flex 3,Flash player 10.1

       

       

      Thanks in advance..

       

       

      Regards,

      Satya

        • 1. Re: In Flex application functionality is working sometimes and not working sometimes..
          BhaskerChari Level 4

          Hi Satya,

           

          Are you using RemoteObject in order to fetch data from your Server...?? You say that the first time you are getting the data and is showing up correctly in ComboBox. But the second time is throwing an error.

           

          If you are using RemoteObject then have you specified the [RemoteClass(alias="your_serverside_class")] on the AS class..??

           

           

           

          Thanks,

          Bhasker

          • 2. Re: In Flex application functionality is working sometimes and not working sometimes..
            satyasuppu Level 1

            Hi Bhasker,

             

            Thank you so much for your reply..

             

              Yes iam using the RemoteObject inorder to get data from server..

             

            This is my AS class:::

             

             

            package com.expeditor.ScriptAdmin.Objects
            {
                import mx.collections.ArrayCollection;
               
                [Bindable]
                [RemoteClass (alias="com.expeditor.ScriptAdmin.Objects.CustomerList")]
               
                public class CustomerList
                {
                    public var arryCollCustName:ArrayCollection = new ArrayCollection();
                    public var arryCollCustId:ArrayCollection = new ArrayCollection();
                   
                }
            }

             

            Thanks,

            satya

            • 3. Re: In Flex application functionality is working sometimes and not working sometimes..
              BhaskerChari Level 4

              Hi Satya,

               

              This sometimes as in your case might not work as the way you have specified the RemoteClass attribute in your AS class. As somtimes there may be a case as before it is mapped to a server side you are returned the data and so that you may not get the data as your Custom class but as normal Object type.

               

              So in order to avoid this you can map the server side class to AS classes in the PreInitialize handler itself as shown below:

               

              Specify the preinitializeHandler in your main application and write the below function.This way also you can map AS classes with the server side. So that you will not have any problem referring your application as AS class types.

               

              You can use the same line for registering all the classes. By using this you can remove all the  [RemoteClass] attributes on all AS classes and include it at single place.

               

              preinitialize="onPreinitialize()"

               

              private function onPreinitialize():void
              {
                registerClassAlias("com.expeditor.ScriptAdmin.Objects.CustomerList", CustomerList);
              }

              Here in the above line of code the string in quotes refer to the namespace of the Server side class and the latter is your AS class. Also dont forget to import the namespace of the corresponding AS class in the file.

               

              Try this and let me know..

               

               

              Thanks,

              Bhasker

              • 4. Re: In Flex application functionality is working sometimes and not working sometimes..
                satyasuppu Level 1

                Hi Bhasker,

                 

                Thanks  alot for you reply and the information u have given..

                 

                Its working fine now after putting the changes which u have mentioned below..

                 

                Thank you so much..

                 

                Regards,

                Satya