List of usage examples for com.vaadin.data Binder validate
public BinderValidationStatus<BEAN> validate()
From source file:org.jpos.qi.minigl.NewEntryForm.java
License:Open Source License
private Button.ClickListener addEntryClickListener(Binder binder) { return event -> { if (binder.validate().isOk()) { if (binder.writeBeanIfValid(binder.getBean())) { GLEntry entry = (GLEntry) binder.getBean(); int count = 0; List<GLEntry> newEntriesList = new ArrayList<>(); for (GLEntry e : transaction.getEntries()) { e.setId(count);//from ww w . j a v a 2 s.c om newEntriesList.add(e); count++; } if (entry.isCredit()) { GLCredit credit = new GLCredit(); credit.setAccount(entry.getAccount()); credit.setAmount(entry.getAmount()); credit.setLayer(entry.getLayer()); credit.setDetail(entry.getDetail()); credit.setTags(entry.getTags()); credit.setTransaction(entry.getTransaction()); credit.setId(count); newEntriesList.add(credit); } else if (entry.isDebit()) { GLDebit debit = new GLDebit(); debit.setAccount(entry.getAccount()); debit.setAmount(entry.getAmount()); debit.setLayer(entry.getLayer()); debit.setDetail(entry.getDetail()); debit.setTags(entry.getTags()); debit.setTransaction(entry.getTransaction()); debit.setId(count); newEntriesList.add(debit); } transaction.setEntries(newEntriesList); entryGrid.setValue(transaction); clearFields(); shouldReverse = true; entryGrid.setComponentError(null); } } else { BindingValidationStatus<?> result = (BindingValidationStatus<?>) binder.validate() .getFieldValidationErrors().get(0); app.displayNotification(result.getResult().get().getErrorMessage()); } focusOnFirstField(); }; }