List of usage examples for com.vaadin.data BindingValidationStatus getResult
public Optional<ValidationResult> getResult()
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 w w w . j ava 2 s.com*/ 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(); }; }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
protected boolean saveClick(Button.ClickEvent event, Layout formLayout) { if (binder.validate().isOk()) { if (getEntity(bean) == null) { try { saveEntity();//ww w . j a v a 2 s . c o m } catch (BLException e) { getApp().getLog().error(e); getApp().displayNotification(e.getDetailedMessage()); return false; } } else { try { updateEntity(); } catch (BLException e) { getApp().getLog().error(e); getApp().displayNotification(e.getDetailedMessage()); return false; } } binder.setReadOnly(true); formLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); event.getButton().setVisible(false); cancelBtn.setVisible(false); editBtn.setVisible(true); removeBtn.setVisible(true); errorLabel.setValue(null); errorLabel.setVisible(false); if (revisionsPanel != null && revisionsPanel.getParent() != null) { Layout parent = (Layout) revisionsPanel.getParent(); parent.removeComponent(revisionsPanel); loadRevisionHistory(parent, revisionsPanel.getRef()); } return true; } else { BindingValidationStatus<?> result = binder.validate().getFieldValidationErrors().get(0); getApp().displayNotification(result.getResult().get().getErrorMessage()); return false; } }