
14. Define the following set function. The function passes the F3DesktopApplication object to the AccountsView
component using app="{app}" attribute, and assigns the F3DesktopApplication object to the _app variable you
declared earlier in the ActionScript code.
public function set app( app : F3DesktopApplication ) : void {
_app = app;
_desktopWrapper = app.wrapper;
}
15. Create the event handlers for the Create, Query, and Sync buttons. Use the following functions:
•
onCreateClick—Renders the UI where the user creates the new account.
•
onSyncClick—Synchronizes the local database with the Salesforce database and updates the status.
•
onQueryClick—Sends a query to the local database to retrieve all the Account records, and calls onQueryResult, a
function we will write that displays the new list of records.
The code looks like this:
protected function onCreateClick() : void {
_app.setStatus( null );
// switch to create mode and simply render a new account
currentState = "create";
_createFieldContainer.fieldCollection.render( new Account());
}
protected function onSyncClick() : void {
_app.setStatus( null );
_desktopWrapper.syncWithServer(
null,
new mx.rpc.Responder(
function( result : F3Message ) : void {
_app.setStatus( result );
},
function( result : F3Message ) : void {
LOG.error( "syncWithServer failed: " + result.toString());
}
)
);
}
protected function onQueryClick() : void {
_app.setStatus( null );
_desktopWrapper.query(
"select * from Account",
new mx.rpc.Responder(
onQueryResult,
function( result : F3Message ) : void {
LOG.error( "query failed: " + result.toString());
}
)
);
}
21
Step 8: Create the Account Manager User Interface and
Application Logic
Komentáře k této Příručce