Thursday, August 14, 2008

Add Commands

Inside a data collector flow you can browse forward and backwards through pages.
What if the user needs to access another Midlet screen in the middle of data input ?
What if the user decides to abort the data input ?

Diamond Powder provides the possibility to add commands at will to a collector, because a collector is a Form. The only issue you must keep in mind is that you can have just one OK button and just one BACK button. Besides that, you are able to add how many SCREEN, CANCEL, EXIT commands you want, and wire them with other components inside your Midlet.



The add-cmd-diammond-powder example introduces a CANCEL command in the collector. From a command you can perform any navigation logic. In our example we'll see a alert screen preventing user from loss of data, and thus the possibility to go back to the current collector.

There is no surprise in source code:

collector = new Collector(getDisplay(), getSchema(), "basicRecord");
collector.setTitle("collector");
collector.addCommand(getOkCommand1());
collector.addCommand(getBackCommand());
collector.addCommand(getCancelCommand());
collector.setCommandListener(this);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.