16 Replies Latest reply on Sep 22, 2011 5:56 AM by whitefinger

    Refreshing the data!!!!

    whitefinger Level 1



      i added this function to the "Selected" state so that hopefuly the clientID would keep changing and so that the user would select the correct client from a list


      protected function rect1_activateHandler(event:Event):void

                      clientId = "0";
                      clientId = clientIdNumber.text;


      The problem is now when i select the user all the clients info  appears, but if i go back to the list of all users and select someone  different the last selected user appears instead and that is why i have  the  clientId = "0"; to initialize the variable but that didnt work!


      I dont know if i have explained this well enough! am i looking for some refresh command?


      any thoughts?

        • 1. Re: Refreshing the data!!!!
          miguel8312 Level 3

          white finger

          i dont quite follow. but the arraycollection does have a refresh property. are you saying that your component have different states?  and one specific state you see all the data but on another you only see the last persons data?

          I just dont follow.


          • 2. Re: Refreshing the data!!!!
            betheflexcoder Level 2

            If you are using a list, you should probably do


            listId.selectedIndex = -1 for resetting.

            • 3. Re: Refreshing the data!!!!
              whitefinger Level 1

              ar miguel8312 coming to me rescure again


              Well say i got my Main page where i can choose to select one of  many client's "Client 1 to Client 9"


              So the user select's the client of interest say "Client 4" which open page 2 and shows all information of the selected client


              The user can then select the home button which takes them back to Main page where they can select a diffrent client say "client 7" which open's page 2 show all the clients information.


              But the second time round it just shows the information of the previous choice being "Client 4" and not "Client 7"


              The only way i seem to get round this is if i press the F5 key which refreshes the page and then the user can select a diffrent client say "Client 6" and then page 2 shows the information of Client 6.


              any idea's what im missing?

              • 4. Re: Refreshing the data!!!!
                whitefinger Level 1

                ok if it helps im using a DataGroup Repeated Item with a DataProvider and a ItemRenderer !

                • 5. Re: Refreshing the data!!!!
                  miguel8312 Level 3


                  miguel8312 coming to me rescure again 

                  this is pretty funny.


                  I'm just paying it forward i have been over my head countless time and needed to be rescue.


                  ok so it sound to me like you have a couple of components and you are switching view states by basically changing states? I'm i correct.

                  then it sounds like when user picks an item from the list the application changes states? right?

                  The user can then select the home button which takes them back to Main page where they can select a diffrent client say "client 7" which open's page 2 show all the clients information.

                  what you can do here is basically capture the home button click event, and refresh the dataprovider.

                  if you need a little help can you send me your project via private message and i can compile on my side attempt to fix it and i will send it back to you.

                  or you can also try what beth says below.

                  listId.selectedIndex  = -1.



                  Message was edited by: miguel8312

                  • 6. Re: Refreshing the data!!!!
                    miguel8312 Level 3

                    Wait i just reread your question you dont have a problem with the list of clients. you have a problem with the time they hit home when they click back the  list on the second page does not update with the new selected client information right? if thats the case this means to me that when you select the client on page 1 you need to send an event or update your provider with the new information.  so if you have an arraycollection as your provider you can do

                    arrarycollection.Removeall and then add your new client information to it.

                    Hopefully this makes sense.


                    • 7. Re: Refreshing the data!!!!
                      whitefinger Level 1

                      yes miguel8312 i think you may know what im trying to say, so when the user selects one of the clients on page Main the "state" of that particular client  state  "Select" fires an event


                      protected function rect1_activateHandler(event:Event):void
                                      ClientId = ClientIdNumber.text;   // which is the id of the client


                      which fires on the event that the users has selected a client which then opens up a component which is page 2 showing all the information of the client


                      When the user goes back to the main to select a diffrent Client when the event is triggered again "page 2 is still showing the old clients information"


                      but if i first @ the main page push the refresh button on the browser of F5 and then select the diffrent client then page 2 shows the correct client!

                      • 8. Re: Refreshing the data!!!!
                        miguel8312 Level 3

                        i can help you fix this but i need to see some more code to debug... i cant really see whats failing. the one thing i can think about is the fact that the dataprovider is not getting updated with the new client info.



                        • 9. Re: Refreshing the data!!!!
                          whitefinger Level 1

                          I wonder if this could be my problem?


                          On page 2 where the data doesnt refresh i have a WARNING on where each item gets [binded]


                          so on one spark RichText object where i display the users first name and last name i get the error


                          ERROR: Data binding will not be able to detect changes when using square bracket operator. For Array, please use ArrayCollection.getItemAt() instead.



                          <s:RichText id="ClientFname" d:userLabel="ClientName" x="257" y="165" color="#fafaf7"
                                          creationComplete="ClientFname_creationCompleteHandler(event)" fontFamily="Myriad Pro"
                                          fontSize="24" kerning="off" lineHeight="120%" textAlign="center"
                                          verticalAlign="middle" whiteSpaceCollapse="preserve">


                          But when ever i try and change {getClientResult.lastResult[0].lname} to what the error says the WARNING  turns to an ERROR


                          on all the other pages that i have a dataprovider bind to i use this


                          <s:RichText d:userLabel="Name" x="46" y="6" color="#f9fcf8" fontFamily="Myriad Pro"
                                              fontSize="13" kerning="off" lineHeight="120%" text="{data.lname}"


                          which works great. i have tryed to use text="{data.lname}" in the first <s:RichText but it doesnt like it for some odd reason

                          • 10. Re: Refreshing the data!!!!
                            miguel8312 Level 3

                            the only way i can further help you is if i can see your code. Sorry man but i just cant conceptualise where the problem is.

                            I think that error your getting now its just a red herring. Ive seen it before but it typically still lets you bind.

                            if you want to zip your project up and send it to me you can send private message me and ill send you my e-mail address. I have seen people actually attach zip files here but i have to figuered how they do it. i think is restricted to the admin.


                            1 person found this helpful
                            • 11. Re: Refreshing the data!!!!
                              whitefinger Level 1

                              Thanks for the offer miguel8312 and i wish i could take you up on it but this is my first web site in Flash Builder and im in no rush, and their is apart of me that loves not completing it and just keep stabbing in the dark! just wish i could say the correct words to get your brain sparked with idea's.


                              So if you dont mind i will still keep putting idea's up here to see if it sparks any ones thoughts!


                              the only diffrents i can see between this page and the others is that this page doesnt have a  dataProvider or a itemRenderer statement in it but it gets the data borrowed from the other page i wonder if a lack of itemRenderer is the reason the site doesnt refresh a second time round!

                              • 12. Re: Refreshing the data!!!!
                                whitefinger Level 1

                                hay  miguel8312 i think i found the code to resolve my issue i dont think its the best answer but i ran out of options!


                                well after searching all day for  my answer to resolve my issue i decided to look for a way to  programmatically refresh the page to show the new data well i found  this!


                                http://flexonblog.wordpress.com/2008/02/12/refreshreload-flex-app-usin g-javascript-code/


                                protected function reloadpage(event:MouseEvent):void
                                                var ref:URLRequest = new URLRequest("javascript:location.reload(true)");
                                                navigateToURL(ref, "_self");



                                • 13. Re: Refreshing the data!!!!
                                  miguel8312 Level 3

                                  i would strongly suggest against that solution. You are basically doing a full page refresh. Doing that

                                  can have unwanted side effects. Your problem has a much better solution.

                                  but i strongly believe this one is not it. I would only do a full page refresh it want to put a log out button on my application, and even then is a bad idea because i should just use states to take me back to the state that includes the login screen. good luck with everything and i hate to be the bear of bad news but i dont think that refreshing the entire page is what you want.


                                  1 person found this helpful
                                  • 14. Re: Refreshing the data!!!!
                                    whitefinger Level 1

                                    Yeah your right miguel8312 that is bad news and i was in such a good mood . But not your thought and yes i do agree with you so i better re think i suppose, many thanks for your contribution

                                    • 15. Re: Refreshing the data!!!!
                                      whitefinger Level 1

                                      miguel8312 when you told me that i was wrong i new you were right, but i had no idea where to start .

                                      But have been a work the last few days so havent done much .

                                      Anyway i decided to put some TEST buttons on my page one to remove all the data from the array and another to try and update the array, the funny thing is the update doesnt work but if i leave the page for about a minute it does! lol looks like i still have a little more playing to do


                                      protected function button1_clickHandler(event:MouseEvent):void
                                                      var item2:String = ClientProfile1DataListSkin1RepeatedItemSkin.ClientId;
                                                      getclientResult.token = customerService.getClient(item2);
                                                    ScrollPanelSkinClientScrollingContentSkin.clientArray.itemUpdated(ScrollPanelSkinClientSc rollingContentSkin.clientArray.getItemAt(1).Pic_loc);    


                                      well actualy what seems to meto be  happening is if i click of the website and then back on it and click the upadte button then it will give me the next selected data!!

                                      • 16. Re: Refreshing the data!!!!
                                        whitefinger Level 1

                                        Well after searching for a month and thinking perhaps flex wasnt capable for dynamic web sites i decided to start again with my search


                                        Turns out that the answer was really simple as all way just had to clear my mind and think a little


                                        protected function itemrenderer1_mouseOverHandler(event:MouseEvent):void


                                                        Main.ClientData.ClientsID = clientIdNumber.text;

                                                        ScrollPanelSkinClientScrollingContentSkin.getClientResult.token = ScrollPanelSkinClientScrollingContentSkin.customerService.getClient(Main.ClientData.Clien tID);

                                                        trace("Trace one113 "+ Main.ClientData.ClientID);




                                        As all ways, how stupid do i feel