4 Replies Latest reply on Nov 25, 2008 8:16 AM by rtalton

    Best way to lay this out?

    peteandrus
      I have a component that will hold a Tree. In that tree are certain types of Objects, called 'JReport' objects. Whenever a JReport Object is clicked, i want to notify a bunch of different components. Some of these have the same parent as the Tree, but most do not.

      What is the best way to design this? I want it to be as 'black-box' as possible, so no passing objects around if i can help it. Any suggestions? thanks!
        • 1. Re: Best way to lay this out?
          *gsb* Level 1
          Lood at the 'event aggregator design pattern' perhaps.
          Here is a google search key to try:
          +flex +"design pattern" +"event aggregator"

          HTH
          • 2. Re: Best way to lay this out?
            peteandrus Level 1
            Greg,
            thanks for the response. i tried that google search, but only got back pages with C# stuff in them. Is there a specific class that sets this up, or is this strictly a design consideration? i assume the latter, but want to know if there's any hope for the former! thanks, peter
            • 3. Re: Best way to lay this out?
              Level 7

              "peteandrus" <webforumsuser@macromedia.com> wrote in message
              news:ggfvkj$sje$1@forums.macromedia.com...
              >I have a component that will hold a Tree. In that tree are certain types of
              > Objects, called 'JReport' objects. Whenever a JReport Object is clicked, i
              > want
              > to notify a bunch of different components. Some of these have the same
              > parent
              > as the Tree, but most do not.
              >
              > What is the best way to design this? I want it to be as 'black-box' as
              > possible, so no passing objects around if i can help it. Any suggestions?
              > thanks!

              The Observer pattern is a good one for this. Luckily, Flex's binding
              architecture already implements this pattern. Create a model object that
              you change a property of based on what object has been clicked, then bind
              all the views to that property.

              HTH;

              Amy


              • 4. Re: Best way to lay this out?
                rtalton Level 4
                You might also consider dispatching a custom event when the object is clicked. Listeners could then be added to each component which needs to be notified, and the listener would handle all the components' responses.