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.

5 responses

  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,<br />You are right, that was the old name. Thanks for catching that. <br /><br />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. <br /> <br />Because having any kind of reference to the view would couple those two things, I would instead either use a property in a &quot;manager&quot; 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.
  3. Can we use <a href="DataCopier</a>">http://mate.asfusion.com/page/documentation/tags/datacopier">DataCopier</a>; to share data between modules?
  4. Unfortunately, the DataCopier isn't type-safe, meaning it doesn't give you a compile-time error if the sourceKey or destinationKey do not exist and the source/target is not dynamic.<br />What is the proper solution?<br />Unsing the InlineInvoker would be nice, if I could write my single line assignment statement right in there, but it expects a function, unlike Flex event tags that accept any AS code.<br /><br />&lt;EventHandlers type=&quot;myEvent&quot;&gt;<br /> &lt;InlineInvoker method=&quot;myModel.someProperty = event.someValue&quot; /&gt;<br />&lt;/EventHandlers&gt;
  5. i have a collection of objects Contact.<br />in a view, i select a Contact in my collection, and modify some properties.<br />then, i want to update it to the the server.<br /><br />so, i put my Contact in an event (=&gt; event.contact), and in a localEventMap, i call a remoteService to update this contact to the server.<br />the server do his job and return me a new Contact updated =&gt; resultObject<br /><br />in my collection, i want to have resultObject taking the place of the old contact (this which was stored in event.contact)<br /><br />here is my code :<br /><br />&lt;EventHandlers type=&quot;{ContactEvent.UPDATE_CONTACT}&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&lt;RemoteObjectInvoker <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;instance=&quot;{ServiceProfilSingleton.instanceContactUserService}&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method=&quot;update&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arguments=&quot;{[event.contact]}&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debug=&quot;false&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;concurrency=&quot;last&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;resultHandlers&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;InlineInvoker <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method=&quot;{contactManager.populateContact}&quot; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arguments=&quot;{[event.contact, resultObject]}&quot;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/resultHandlers&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;faultHandlers&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;InlineInvoker <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;method=&quot;{contactManager.onFaultError}&quot; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arguments=&quot;{fault}&quot;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/faultHandlers&gt;<br />&nbsp;&nbsp;&nbsp;&lt;/RemoteObjectInvoker&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&lt;/EventHandlers&gt;<br /><br />in contactManager.populateContact()<br />i do : contact = resultObject;<br />but it does nothing, because, i my collection i keep the old contact.<br /><br />how can i do this ?

Comments now closed