private Button.ClickListener deleteAccount() { return event -> { @SuppressWarnings("unchecked") final BeanFieldGroup<Account> tabBinder = view.getCurrentTabBinder(); final Account selectedAccount = tabBinder.getItemDataSource().getBean(); if (selectedAccount.getId() != null) { accountService.deleteByObjectId(selectedAccount.getId()); } loadTabs(); }; }
private Button.ClickListener saveAccount() { return event -> { @SuppressWarnings("unchecked") final BeanFieldGroup<Account> tabBinder = view.getCurrentTabBinder(); try { TextFieldVisitatorEngine.visit( view.getSelectedAccountForm(), new ValidationVisibleVisitator(true)); tabBinder.commit(); } catch (FieldGroup.CommitException e) { throw new ValidationException("validation error", e); } accountService.save(tabBinder.getItemDataSource().getBean()); loadTabs(); }; }
private void loadTabs() { final List<Account> accountList = accountService.getAllAccounts(); view.removeAllTabs(); accountList.forEach(account -> view.addTab(account.getName(), account, false)); }