Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DataSource reuse

    In my implementation it will be common for their to be multiple databound components bound to the same DataSource.

    So for example I have a DataSource foo.ds.xml. Can I cache the result of DataSource.get("foo") and reuse the foo instance to bind n components?

    Secondly, I am using realtime messaging to inform clients that DataSource foo has changed, and so all widgets bound to foo need to update their view. If I can reuse foo among all widgets, can I then call foo.fetchData() and then have the widgets redraw themselves to represent the new state of foo?

    If this type of DataSource reuse in not possible, what would be the best practice if I have n instances of widgets bound to foo, but only y widgets are actually visible? Ideally, to reduce the overhead of server trips to only the y visible widgets, and have the n-y other widgets know they have stale data, and that when they become visible again they need to update their records before redrawing?

    Thank you for your clarification on this matter.

    #2
    Yes, you can reuse the same DataSource instance with multiple components. Note, don't do this in server-side code, where DataSource instances are pooled.

    DataSource.updateCaches() can be used to broadcast changes to all components that use a DataSource. DataSource.invalidateCache() can cause all components to dump their cache - this will cause an automatic re-fetch for a component such as a ListGrid.

    Comment


      #3
      I am also wanting to reuse a DataSource. I have two different selectItems, in two different DynamicForms, using the same optionDataSource.

      I defined the dataArrived function for both selectItems. However, when either selectItem fetches data, the same dataArrived function gets called. Meaning I fetch for item1, which results in item1.dataArrived getting called. I then fetch for item2, and the item1.dataArrived still gets called.

      Can only one DataArrived function be defined per DataSource?

      Comment


        #4
        Because of automatic caching behavior, DataArrived can be (correctly) triggered by interacting with another component. This does not imply any issue with sharing DataSources.

        Comment


          #5
          I don't follow. So, how do I trigger the dataArrived (correctly) for the item which requested the fetch? Currently, the same dataArrived function gets triggered regardless of which item is requesting the fetch.

          If I use an identical DS, for the two items, the dataArrived gets called correctly. However, I would like to reuse the dataSource.
          Last edited by subashk; 10 May 2012, 14:09.

          Comment


            #6
            You don't trigger DataArrived. DataArrived is triggered when data is loaded.

            Again, DataArrived may be triggered *by the system* when you are not actually interacting (keyboard or mouse) with the component where DataArrived fires. And this is expected.

            Comment

            Working...
            X