DataCopier

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

The DataCopier tag allows you to save values into some object. A possible storage is the "data" object available while the sequence is running.

<DataCopier destination="data" destinationKey="someProperty" source="result" sourceKey="someProperty" />

The DataCopier tags is a handy tag to quickly copy values from a source into some storage. You can use the event handlers scope "data" as a temporary storage from where handlers that follow in the list can read values. You can also use some other external variable as the storage.

Attributes

source

The source attribute specifies where to get the data to copy from. It can be one of this options:

  • event
  • data
  • result
  • fault
  • lastReturn
  • message
  • scope
  • currentEvent (maybe the same or different from the event if the tag is placed inside a resultHandlers block, faultHandlers block or any handlers block other than EventHandlers and MessageHandlers.

or another object. If you wish to specify another object, you need to use bindings:

<DataCopier source="{myModel}" ... />

sourceKey

If you need a property from the source instead of the source itself, you need to specify this attribute.

destination

The destination attribute specifies where to place the data. It can be one of this options:

  • event
  • data
  • result

or another object.

<DataCopier destination="{myModel}" ... />

destinationKey

If you want to set the value of a property of the destination object, instead of the destination itself, you need to specify this attribute.

2 responses so far

  1. I noticed two references to DataSaver elements on this page. Was DataSaver an old name for DataCopier?

    Also, how would one use the scope and data attributes?

    How would I copy from a property called text from a custom event of type StatusBarEvent to an mx:Label's text property with id statusMsg? Here is my best guess:

    <EventHandlers type="{StatusBarEvent}">
    <DataCopier
    destination="statusMsg"
    destinationKey="text"
    source="event"
    sourceKey="text" />
    </EventHandlers>
  2. Hi Mike,
    You are right, that was the old name. Thanks for catching that.

    Regarding what you want to do, if you want to use an object that is not one of the pre-defined ones (event, result, etc), you need to use bindings to point to that object. Because of that, the event map needs to have access to that object, that is be defined within the event map, as opposed as in the view.

    Because having any kind of reference to the view would couple those two things, I would instead either use a property in a "manager" or use the Dispatcher + ResponseAnnouncer/ResponseHandler. If the view that dispatches the event is not the same as the one that needs to show the message, I would use a Listener tag in the view that wants to show the message or use a property in the manager (if that is shared data) + Injectors.

Leave a response

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