/** * Runs all currently configured field level validators, as well as all bean * level validators if a bean is currently set with * {@link #setBean(Object)}, and returns whether any of the validators * failed. * <p> * <b>Note:</b> Calling this method will not trigger status change events, * unlike {@link #validate()} and will not modify the UI. To also update * error indicators on fields, use {@code validate().isOk()}. * <p> * <strong>Note:</strong> This method will attempt to temporarily apply all * current changes to the bean and run full bean validation for it. The * changes are reverted after bean validation. * * @see #validate() * * @return whether this binder is in a valid state * @throws IllegalStateException * if bean level validators have been configured and no bean is * currently set */ public boolean isValid() { return validate(false).isOk(); }
/** * Writes changes from the bound fields to the given bean if all validators * (binding and bean level) pass. * <p> * If any field binding validator fails, no values are written and * <code>false</code> is returned. * <p> * If all field level validators pass, the given bean is updated and bean * level validators are run on the updated bean. If any bean level validator * fails, the bean updates are reverted and <code>false</code> is returned. * * @see #writeBean(Object) * @see #readBean(Object) * @see #setBean(Object) * * @param bean * the object to which to write the field values, not * {@code null} * @return {@code true} if there was no validation errors and the bean was * updated, {@code false} otherwise */ public boolean writeBeanIfValid(BEAN bean) { return doWriteIfValid(bean, new ArrayList<>(bindings)).isOk(); }
bindingResults, binderResults); getValidationStatusHandler().statusChange(status); fireStatusChangeEvent(!status.isOk()); return status;
if (status.isOk()) {
private Button.ClickListener addEntryClickListener(Binder binder) { return event -> { if (binder.validate().isOk()) { if (binder.writeBeanIfValid(binder.getBean())) { GLEntry entry = (GLEntry) binder.getBean();