3 Replies Latest reply on Aug 19, 2006 3:00 AM by TIPLVinay

    Adding new record - Displaying in real time.

    jmortimer Level 1
      Basically I have a combo box that shows a sequence of numbers populated by a datasource.
      Item 1 = "1"
      Item 2 = "2" etc.
      I want to hit a button, creating a new record, which would increase the number of records in the combo box. I've got the button hitting the database to add the record just fine, but the function my button calls, also reloads the data, to the combo box, from the HTTPService - at the same exact time - but the records were'nt added yet in the database (just barely, though sometimes it actually does work). So I hit the button, and it looks as if nothing happens, because my HTTPService is hiting the same old data.

      Is there a way for flex to get a "signal" to send the second Http post after a trigger is set or something? Or am I just thinking way outside of a better way to handle this?
        • 1. Re: Adding new record - Displaying in real time.
          peterent Level 2
          When you hit the button, don't add it to the ComboBox - make the request to the server and in the HTTPService result handler, add the value to the ComboBox. This way you are guaranteed the value to be in the database.
          • 2. Re: Adding new record - Displaying in real time.
            Matlus Level 1
            First of all I think the implementation on your server side is not "perfect" :). You're probably not using transaction controll correctly or something. Anyway, Perter's suggestion is (IMO) a better way, except that I'd like to add to it is it's not too clear.

            Steps:
            (Assuming you're "programming to exceptions" meaning that if you're executing a line of code, then the line before it executed just fine)

            1. Post the new record to the database first.
            2. Add the new record to your combo box.

            In other words, there is no need to reload the entire record set each time you add a single record. Of course that's the general thing. In a multi-user environment (and depending on your reconcilliation rules) you may want to re-load just in case some other users also added new records.

            my two cents.
            • 3. Re: Adding new record - Displaying in real time.
              TIPLVinay Level 1
              I think peter is right.
              Because if 100 users adds records in a mean time Surely U wanna see Real Time Data.
              So it is mandatory to get always updated data from the server.