List of usage examples for com.vaadin.server AbstractErrorMessage getErrorMessageForException
public static ErrorMessage getErrorMessageForException(Throwable t)
From source file:de.metas.procurement.webui.server.AbstractErrorHandler.java
License:Open Source License
private ErrorMessage createErrorMessage(final Throwable t) { final ErrorMessage errorMessage = AbstractErrorMessage.getErrorMessageForException(t); // In case we deal with an System Error, don't show it to user because it's confusing. // Instead show a generic friendly error message. if (errorMessage instanceof SystemError) { return new UserError(i18n.get("error.default")); }/*from w w w.j a v a2 s .c o m*/ return errorMessage; }
From source file:org.vaadin.viritin.fields.MPasswordField.java
License:Apache License
@Override public ErrorMessage getErrorMessage() { Validator.InvalidValueException validationError = getValidationError(); final ErrorMessage superError = getComponentError(); if (superError == null && validationError == null && getCurrentBufferedSourceException() == null) { return null; }// w w w.j av a 2s . c o m // Throw combination of the error types return new CompositeErrorMessage( new ErrorMessage[] { superError, AbstractErrorMessage.getErrorMessageForException(validationError), AbstractErrorMessage.getErrorMessageForException(getCurrentBufferedSourceException()) }); }
From source file:org.vaadin.viritin.MBeanFieldGroup.java
License:Apache License
@Override public boolean isValid() { // clear all MValidation errors clearMValidationErrors();//from w w w . j a v a 2 s . c o m jsr303beanLevelViolations = null; beanLevelViolations = null; // first check standard property level validators final boolean propertiesValid = super.isValid(); // then crossfield(/bean level) validators, execute them all although // with per field validation Vaadin checks only until the first failed one if (propertiesValid) { boolean ok = true; for (MValidator<T> v : mValidators.keySet()) { try { v.validate(getItemDataSource().getBean()); } catch (Validator.InvalidValueException e) { Collection<AbstractComponent> properties = mValidators.get(v); if (!properties.isEmpty()) { for (AbstractComponent field : properties) { final ErrorMessage em = AbstractErrorMessage.getErrorMessageForException(e); mValidationErrors.put(em, field); field.setComponentError(em); } } else { final ErrorMessage em = AbstractErrorMessage.getErrorMessageForException(e); AbstractComponent target = validatorToErrorTarget.get(v.getClass()); if (target != null) { target.setComponentError(em); } else { // no specific "target component" for validation error // leave as bean level error if (beanLevelViolations == null) { beanLevelViolations = new HashSet<Validator.InvalidValueException>(); } beanLevelViolations.add(e); mValidationErrors.put(em, null); } } ok = false; } } return jsr303ValidateBean(getItemDataSource().getBean()) && ok; } return false; }
From source file:org.vaadin.viritin.v7.MBeanFieldGroup.java
License:Apache License
private boolean isValidAllProperties() { // clear all MValidation errors clearMValidationErrors();// w w w .java 2 s . c om jsr303beanLevelViolations = null; beanLevelViolations = null; // first check standard property level validators, but unlike in Vaadin // core, check them all, don't stop for first error boolean propertiesValid = true; try { for (Field<?> field : getFields()) { field.validate(); } } catch (Validator.InvalidValueException e) { propertiesValid = false; } // then crossfield(/bean level) validators, execute them all although // with per field validation Vaadin checks only until the first failed one boolean ok = true; for (MValidator<T> v : mValidators.keySet()) { try { v.validate(getItemDataSource().getBean()); } catch (Validator.InvalidValueException e) { Collection<AbstractComponent> properties = mValidators.get(v); if (!properties.isEmpty()) { for (AbstractComponent field : properties) { final ErrorMessage em = AbstractErrorMessage.getErrorMessageForException(e); mValidationErrors.put(em, field); field.setComponentError(em); } } else { final ErrorMessage em = AbstractErrorMessage.getErrorMessageForException(e); AbstractComponent target = validatorToErrorTarget.get(v.getClass()); if (target != null) { target.setComponentError(em); } else { // no specific "target component" for validation error // leave as bean level error if (beanLevelViolations == null) { beanLevelViolations = new HashSet<>(); } beanLevelViolations.add(e); mValidationErrors.put(em, null); } } ok = false; } } return jsr303ValidateBean(getItemDataSource().getBean()) && ok && propertiesValid; }
From source file:org.vaadin.viritin.v7.MBeanFieldGroup.java
License:Apache License
private boolean isValidLegacy() { // clear all MValidation errors clearMValidationErrors();// w ww . j a v a 2 s. c om jsr303beanLevelViolations = null; beanLevelViolations = null; // first check standard property level validators final boolean propertiesValid = super.isValid(); // then crossfield(/bean level) validators, execute them all although // with per field validation Vaadin checks only until the first failed one if (propertiesValid) { boolean ok = true; for (MValidator<T> v : mValidators.keySet()) { try { v.validate(getItemDataSource().getBean()); } catch (Validator.InvalidValueException e) { Collection<AbstractComponent> properties = mValidators.get(v); if (!properties.isEmpty()) { for (AbstractComponent field : properties) { final ErrorMessage em = AbstractErrorMessage.getErrorMessageForException(e); mValidationErrors.put(em, field); field.setComponentError(em); } } else { final ErrorMessage em = AbstractErrorMessage.getErrorMessageForException(e); AbstractComponent target = validatorToErrorTarget.get(v.getClass()); if (target != null) { target.setComponentError(em); } else { // no specific "target component" for validation error // leave as bean level error if (beanLevelViolations == null) { beanLevelViolations = new HashSet<>(); } beanLevelViolations.add(e); mValidationErrors.put(em, null); } } ok = false; } } return jsr303ValidateBean(getItemDataSource().getBean()) && ok; } return false; }