
currentState = "default";
}
17. Create the event handlers for the Save and Cancel buttons that display when the user is creating an account record. The
onCreateSaveClick function commits the new object to the local database. The function onCreateCancelClick
named cancels the current create operation. The code should like this:
protected function onCreateSaveClick() : void {
_app.setStatus( null );
// The new account object has been created in memory.
// Now commit the new object to the database.
_createFieldContainer.fieldCollection.updateObject(
new mx.rpc.Responder( commitToDB, saveFaultHandler )
);
}
protected function onCreateCancelClick() : void {
_app.setStatus( null );
// clear and go back to empty mode
_createFieldContainer.fieldCollection.clear();
currentState = "default";
}
18. Add the following ActionScript functions:
•
saveFaultHandler—Handles errors for invalid fields.
•
commitToDB—Commits the data in memory to the local database and clears the data from the FieldContainer.
•
onDataGridItemClick—Renders the UI and alerts for editing an account.
•
onQueryResult—Stores the results of the query and updates the status.
•
onToasterSelected—Used when displaying toaster alerts.
The code should like this:
protected function saveFaultHandler( msg : F3Message ) : void {
// If there are invalid fields, stay on the edit screen
// so the user has a chance to fix the errors.
// Otherwise, clear the record.
if (
msg != null &&
msg.messageType != F3Message.ERROR_INVALID_FIELDS
) {
currentState = "default";
}
if ( msg != null ) {
var faultEvent : FaultEvent = msg.context as FaultEvent;
if ( faultEvent ) {
LOG.error( faultEvent.fault.faultString );
LOG.error( faultEvent.fault.faultDetail );
LOG.error( faultEvent.fault.faultCode );
}
}
23
Step 8: Create the Account Manager User Interface and
Application Logic
Commentaires sur ces manuels