|« Test Process||Types of Testing »|
I have recently been working on a BlackBerry application, and found that I often got lost in the maze of method calls that happen was a close command is initiated for a screen. To help me keep track of it, I have created a basic flowchart which helps me follow the bouncing ball:
onClose()method to be called.
isDirty()to see if there have been any changes on the screen. If no changes have been made, the
close()method is called and the screen is closed. If changes have been made then the
onSavePrompt()method is called.
onSave()method brings up a Dialog with the following options: "Save", "Discard" and "Cancel". If the user selectes "Cancel" the Dialog is simple closed and the screen remains open. If the user selects "Discard", then the
close()method is called and the screen is closed. If the user selects "Save", then the
onSave()method is called.
onSave()method calls the
isDataValid()returns false, then nothing happens and the original screen is still displayed. If
isDataValid()returns true, the the
save()method is called.
save()method has completed successfull then the close() method is called and the screen is closed.
Typically you will want to override the following:
isDataValid(): You should add you own logic for whether the data is valid or not. Here you can check that the user entered all the necessary data and data is valid.
save(): You should implement how you want to save the data.
You may also want to override the following:
close(): if you have any special actions you want to happen when the screen closes
onSavePrompt(): if you don't want the prompt just override the method and return true. You can also override it, if you want to implement your own dialog with different options, e.g. using
Dialog.ask(). When implementing your own dialog make sure you get the return type correct, the return type boolean is for whether or not you want to close the original screen.
These methods are all part of
Hopefully this will be helpful to some of you.
The above Flowchart can be downloaded as a pdf: BlackBerry Save Model
|<< <||> >>|