
Build a distributed application with the Java adapter 233
Verify that your code is correct
Your code should match the following code example. Verify that the content is correct and
save the lesson2.mxml file.
<?xml version="1.0" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initApp();">
<mx:Script>
<![CDATA[
import mx.data.DataService;
import mx.collections.ArrayCollection;
import samples.contact.Contact;
public var ds:DataService;
[Bindable]
public var contacts:ArrayCollection;
public var contact:Contact;
public function initApp():void {
contacts = new ArrayCollection();
ds = new DataService("contact");
ds.fill(contacts);
}
]]>
</mx:Script>
<mx:DataGrid id="dg" dataProvider="{contacts}" editable="true">
<mx:columns>
<mx:DataGridColumn dataField="contactId" headerText="Id"
editable="false"/>
<mx:DataGridColumn dataField="firstName" headerText="First Name"
/>
<mx:DataGridColumn dataField="lastName" headerText="Last Name"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
Run the completed contact application
In this section, you run the completed contact application in two browser windows to see
automatic updates in one window when data changes in the other.
1. Run the application in two browser windows.
Comentários a estes Manuais