model.addRecord(account); showAlert(Title.record_added, indexFunctionUI, AlertType.CONFIRMATION); } } catch (ApplicationException e) { e.printStackTrace(); } break; } } } 例如在添加新电话记录的时候,我们可以这样实现commandAction()方法向UIController传送消息。 if (arg0 == saveCommand) { …… …… Account newAccount = new Account(userName, mobilePhone, phone, email); uicontroller.handleEvent( UIController.EventID.EVENT_SAVE_RECORD_SELECTED, new Object[] { newAccount }); } 我们很难保证用户输入的数据有效,也很难保证用户的操作都合理,因此我们必须针对用户的不合理的操作给出相对的提示或者警告。在javax.microedition.lcdui包中Alert类能够很好的完成这个任务,因此我们自己提供一个方法如下所示: public void showAlert(String message, Displayable next, AlertType type) {
上一篇:第一个Spring MVC程序
下一篇:在Spring中添加Bean
|