Adobe Flash

Update the timesheet

Now you will set up the bindings to allow the timesheet to be updated.

  1. Begin with the file you created in the "Data Integration: Using XML for a Timesheet (Flash Professional Only)" tutorial.

  2. In the Components panel, open the Data category and drag an XUpdateResolver component to the Stage.

  3. In the Property inspector, enter the instance name timeInfo_rs.

  4. Click the Schema tab in the Component inspector, and select the deltaPacket component property within the Schema Tree pane.

  5. Change the DeltaPacket component's encoder setting to DataSetDeltaToXUpdateDelta.

    This encoder converts data within the DeltaPacket into XPath statements that are supplied to the XUpdateResolver component, but it needs additional information from you to do its job.

  6. Double-click the encoder options property. When prompted for a value for the rowNodeKey property, type datapacket/row[@id='?id'].

  7. This property identifies which node within the XML file will be treated as a record within the data set. It also defines which element or attribute combination makes the row node unique, as well as the schema field within the DataSet component that will represent it. See "Updates sent to an external data source" in Flash Help.

    In the sample XML file, the id attribute of the datapacket/row node is the unique identifier, and it will be mapped to the DataSet component's ID schema field. This is defined with the following expression:

    datapacket/row[@id='?id']
    
  8. In the Component inspector, click the Bindings tab.

  9. Click the Add Binding button.

  10. In the Add Binding dialog box, click the deltaPacket property and click OK.

  11. In the Component inspector Bindings tab, double-click the Bound To property.

  12. In the Bound To dialog box, click the Data Set component, and then click the deltaPacket schema location and click OK.

    This binding will copy the DeltaPacket component to the XUpdateResolver component so that it can be manipulated before it is sent to the server.

    The data is copied after the DataSet component's applyUpdates() method is called.

  13. Drag a TextArea component onto the Stage, and in the Property inspector enter the instance name deltaText.

  14. Still in the Property inspector, set the Width to 360.

  15. Select the component, and then in the Component inspector, click the Bindings tab.

  16. Click the Add Binding button.

  17. In the Add Binding dialog box, click the text: String property and click OK.

  18. In the Bindings tab, double-click the Bound To property.

  19. In the Bound To dialog box, click the XUpdateResolver component, and then click the xupdatePacket schema location and click OK.

    The update packet contains the modified version of the DeltaPacket that will be sent to the server.

  20. In the Components panel, open the User Interface category and drag a Button component onto the Stage.

  21. In the Property inspector, enter the instance name btn_show. In the Component inspector, click the Parameters tab and change the label to Show Updates.

  22. With the button selected, open the Actions panel (F9) and enter the following code:

    on (click) {
    
      _parent.timeInfo_ds.applyUpdates();
    
    }
    
  23. Test the application (Control > Test Movie). Load the data and make a change to one or more fields in multiple records.

  24. Click Show Updates. Review the XML packet in the TextArea component.

  25. Try setting the includeDeltaPacketInfo parameter of the XUpdateResolver component to true using the Component inspector.

You can copy the XML data into your favorite XML editor to make it easier to read.

Additional information is added to the update packet. This information can be used by the server to uniquely identify this update operation. With this information, the server can generate a result packet that can be used by the XUpdateResolver component and the DataSet component to update the client data with changes from the server.