
16. Create the event handlers for the Save, Delete, and Cancel buttons that display when the user edits an account record Use the
following functions:
•
onEditSaveClick—Commits the updated object to the local database.
•
onEditDeleteClick—Deletes the record from the local database, updates the status, and displays a toaster alert.
•
onEditCancelClick—Cancels the current edit operation.
The code should like this:
protected function onEditSaveClick() : void {
_app.setStatus( null );
// The existing account object has been updated in memory.
// Now commit the updated object to the database.
_editFieldContainer.fieldCollection.updateObject(
new mx.rpc.Responder( commitToDB, saveFaultHandler )
);
}
protected function onEditDeleteClick() : void {
_app.setStatus( null );
var account : Account = Account(
_editFieldContainer.fieldCollection.managedObject
);
// clear and go back to empty mode
_editFieldContainer.fieldCollection.clear();
currentState = "default";
_desktopWrapper.deleteItem( account )
var status : F3Message = new F3Message(
F3Message.STATUS_INFO,
"Account deleted"
);
// Show the message in the status bar.
_app.setStatus( status );
// Show the toaster.
_app.showToaster(
new Toaster(
StaticAssets.REPORT_IMAGE_32,
"Account deleted",
status.description
)
);
}
protected function onEditCancel() : void {
_app.setStatus( null );
// clear and go back to empty mode
_editFieldContainer.fieldCollection.clear();
22
Step 8: Create the Account Manager User Interface and
Application Logic
Komentáře k této Příručce