You don't have to attach individual fields as the payload of the event or as 
the information attached to the inside component. There's no problem having the 
internal component created using a class that contains whatever the info is 
available.

For example:

Class info could have attributes colour, description, cost.

Class extendedInfo could extend info and also have company and department 
attributes.

The component could be initialised from an info object, but could be passed an 
extendedInfo object.

Your component could pass the initialisation object ( an info object which may 
actually be an extendedInfo object) as the event payload - that way it can 
either attach info, or extended info to the event - it wouldn't matter either 
way.

When handling the event, just check what kind of object you're working with, or 
for the existence of the extended attributes.

Paul
  ----- Original Message ----- 
  From: Fotis Chatzinikos 
  To: flexcoders@yahoogroups.com 
  Sent: Friday, November 07, 2008 4:39 PM
  Subject: Re: [flexcoders] Adding data to a bubbling event


  Paul that is what i am doing with my components :-) but problems appear if 
you want to reuse your 'inside' components elsewhere
  and this elsewhere 'forgets' (because its not really needed) to initialize 
the component...

  Maybe a solution would be to check if parentComp is set or not and if not set 
throw the event whithout the extra parameters?


  On Fri, Nov 7, 2008 at 6:29 PM, Paul Andrews <[EMAIL PROTECTED]> wrote:


    I'm beginning to wonder if the best solution is for the component to know 
all of the required information - it can be set up when it is instantiated. It 
seems to me that while in most scenarios extending the event payload may work 
it means that the order in which events are handled will be vitally important; 
furthermore you now need two event handlers to service a single event - one to 
extend the payload, one to actually handle the payload.

    Paul
      ----- Original Message ----- 
      From: Fotis Chatzinikos 
      To: flexcoders@yahoogroups.com 
      Sent: Friday, November 07, 2008 4:23 PM
      Subject: Re: [flexcoders] Adding data to a bubbling event


      Hello Andrew, your solution sounds correct. 

      Another way would possibly be to check the parent component (and its 
parent) and manually set all 3 params in one go.



      On Fri, Nov 7, 2008 at 1:00 PM, greenfishinwater <[EMAIL PROTECTED]> 
wrote:

        I have some view components with are used in a heirarchy:

        Application
        Store
        Department
        Product

        Each component only knows about itself, so the data passed to the
        product view only contains product data, and does not contain the
        department or store that the product is within.

        When a product is clicked I dispatch a custom event
        'productSelectedEvent' giving the id of the product selected.

        What I also need is to have the department id and the store id, when
        the event bubbles up to the application. 

        Is it appropriate to have an event listener on 'productSelectedEvent'
        in the department view that adds the current department id to the
        event, and then similarly in Store add the store id to
        'productSelectedEvent'.

        The event 'productSelectedEvent' has 3 custom properties:
        productId
        departmentId
        storeId

        Thanks Andrew







      -- 
      Fotis Chatzinikos, Ph.D.
      Founder,
      Phinnovation
      [EMAIL PROTECTED], 




  -- 
  Fotis Chatzinikos, Ph.D.
  Founder,
  Phinnovation
  [EMAIL PROTECTED], 
   

Reply via email to