Java Reference
In-Depth Information
Your Flex client will consist of a single MXML file containing all of your code and
UI elements. For larger, more complex applications where you have clearly defined
layers, you would typically break up the application into multiple MXML files and
ActionScript classes using an MVC paradigm. Since your application is relatively
small, there is really no need for this type of separation.
As you look at the code for main.mxml in Listing 4-18, pay particular attention
to the RemoteObject tag at the top of the file. The ID of the tag (gateway) is used to
reference the RemoteObject throughout the file, while the destination (Gateway) is
the same destination you set up in your services-config.xml file specifying your
remoting destination of com.appirio.Gateway .
The individual methods specified by the RemoteObject tag map directly to the
public methods in the Gateway class that you will define in Listing 4-18.
Listing 4-18. The Flex UI: main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
width="500" height="400">
<mx:RemoteObject id="gateway" destination="Gateway"
fault="status.text=event.fault.toString();">
<mx:method name="createAccount"
result="status.text='Created.';"/>
<mx:method name="fetchAccount" result="displayAccount(event);"/>
</mx:RemoteObject>
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
// create the account in App Engine
private function createAccount():void {
// submit the create request to App Engine
gateway.createAccount(frmId.text,frmName.text,frmCity.text,frmState.t
ext,frmPhone.text,frmWebsite.text);
// remove current text
status.text=null;
frmId.text=null;
frmName.text=null;
frmCity.text=null;
frmState.text=null;
 
Search WWH ::




Custom Search