4 Replies Latest reply on Oct 24, 2008 9:28 AM by Solerous

    refreshing data via BlazeDS

    Cr99 Level 1
      I have a persistent instance of my Flex App which needs to run constantly and recieve data via server push. It displays the latest data via a chart. The charts are defined in ActionScript. Here is a snippet:

      var lineSeries:LineSeries = new LineSeries();
      BindingUtils.bindProperty(lineSeries, "dataProvider", ser, "pointList"); // pointList is an ArrayCollection
      lineSeries.verticalAxis = vAxis;

      chart.series = seriesArray.toArray().reverse(); // chart is an instance of CartesianChart

      So when I push out the next data to my app, how do I let these lineSeries objects get the new data and redraw the chart?
        • 1. refreshing data via BlazeDS
          Solerous Level 1
          I'm still wondering how to get this working. The underlying ArrayCollection data is being changed with each reload but the charts are staying the same. The data is updated via remoting wiht a Java method, by the way. How do I get the binding to work properly?

          Here is my method which is handling the results

          • 2. Re: refreshing data via BlazeDS
            Solerous Level 1
            It occured to me that since the data is changed remotely on the java side and then passed back, perhaps Flex doesn't pick up on the changed data. Do I have to manually rebuild the charts then with the new data?
            • 3. Re: refreshing data via BlazeDS
              Karl_Sigiscar_1971 Level 3

              Solerous, data binding should take care of it on its own. You don't have to handle it manually. You can even have a nice animation effect when you receive the new data set.

              - I personally use a mere [Bindable] ArrayCollection that my chart is bound to.
              - I create the chart with MXML.
              - I also use the <mx:Binding> tag to bind the chart to the array collection.
              • 4. refreshing data via BlazeDS
                Solerous Level 1
                I have to dynamically create the charts in Actionscript, so my binding is handled with this line:

                BindingUtils.bindProperty(lineSeries, "dataProvider", ser, "pointList"); // pointList is an ArrayCollection

                It works fine for the initialization of the charts (which is when the above line of code gets run), but when I request a new timeframe for the data, the binding does not update the charts. The data is changed in a remote java call and sent back to flex which gets the data via the getReloadResults(event:ResultEvent) function. The actual ArrayCollection is part of the report object however. And so the new data never updates the charts. They remain unchanged after the Result Event is handled.

                Here's a breakdown of how the application works:

                ReportObject report (custom Actionscript/Java object) is created on startup
                Chart is created and assigned data from ArrayCollections in ReportObject via BindingUtils.bindProperty
                User changes parameters, hits 'reload' button and report is sent to remote java method to get the new data
                ReportObject report = the result from the java remote method (but this is not a new object, just the same object with new data)

                ...and charts remain unchanged and never reflect the new data...