
224 Use the Data Management Service
4. Add the boldface text to the <mx:Application> tag to call the initApp() method when
the contact application is initialized:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" height="100%"
width="100%" creationComplete="initApp();"
height="100%" width="100%">
Send notes
In this section, you write an event listener method that sends text to the notes destination
when you click the Send button. You then assign that method to the
click event of the Send
button.
1. Add the boldface text to create two-way binding between the log.text property and the
noteProxy.noteText property:
<mx:Binding source="log.text" destination="noteProxy.noteText"/>
<mx:TextArea id="log" width="100%" height="80%"
text="{noteProxy.noteText}"/>
2.
Add the boldface text to the <mx:Button> tag to call the sendMessage() method when
the Send button is clicked:
<mx:Button label="Send" click="ds.commit();"/>
Handle returned data
In this section, you write an event listener method that handles data that the Data
Management Service returns to the client.
Add the following method just below the
initApp() method:
public function resultHandler(event:ResultEvent):void
{
if (event.token == getToken)
noteProxy = ObjectProxy(event.result);
}
In the resultHandler() method, event.token is the AsyncToken that the getItem()
method returns. Because the noteObj object is an anonymous object, the Data Management
Service wraps it in an ObjectProxy object and returns that object in the result event.
Kommentare zu diesen Handbüchern