(This tag must be placed inside an <EventHandlers> tag)

The CallBack tag allows you to call a method on the event target. The event target is the object that dispatched the event.

<CallBack method="methodToCall" arguments="{['argument1', 'argument2']}" />

The event target that will be called with this tag is always the object that dispatched the event, that is the object on which the method dispachEvent() was called. When the event that triggers the EventHandlers to execute is dispatched by a visual component that let the event bubble up, then the target will be this original dispatcher, the visual component. That is because we usually say "this.dispatchEvent(myEvent)", so "this" is the event dispatcher. However, when the event is dispatched using a different dispatcher ( ie: when you pass an IEventDispatcher to a non-visual component), then the target will be that dispatcher. That is because in those cases we usually say "myDispatcher.dispatchEvent(myEvent), so "myDispatcher" is the event target.





The method to call on the event target. This method must be public.

<CallBack method="dataReceived" ... />



not required

If the function in your event target has arguments, you can pass them via the "arguments" attribute. Suppose your "dataReceived" function has the following signature:

public function dataReceived(name:String, value:Number)

then you can pass those arguments as follows:

   arguments="{['Tom', 36]}"/>

Note that the arguments attribute expects an array. Besides passing literal values, you can pass values coming from the event that triggered the execution of the list of handlers, values coming from a service call, etc. The arguments attribute in the CallBack tag has the same functionality as the arguments in the MethodInvoker. See MethodInvoker for more examples.



not required

targetId can be used to only execute the method call if the event target's id matches the targetId specified. This can be used to distinguish between two different views dispatching the same event.

   method="dataReceived" targetId="dashboard" />
   method="dataLoaded" targetId="customers" />

In the above example, when certain event is dispatched, the method dataReceived will only be called on the target if the target's id is "dashboard", while the method dataLoaded will only be called if the target's id is "customers".

4 responses so far

Leave a response

If you need help or want to comment on something not related to this page, please post in the forums. Thanks!

Leave this field empty