diff options
author | Jarno Rantala <jarno.rantala@vaadin.com> | 2013-06-26 14:56:54 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-07-30 07:45:02 +0000 |
commit | 47f4c612a935ae2d5b9a6ee8626faa41a6451153 (patch) | |
tree | 1829a45a25299810acc67799965bc3dcc448f78d /server/src/com/vaadin/data | |
parent | 41a5d7d952b2ff5c61a1c2a44e8cf116359f0eae (diff) | |
download | vaadin-framework-47f4c612a935ae2d5b9a6ee8626faa41a6451153.tar.gz vaadin-framework-47f4c612a935ae2d5b9a6ee8626faa41a6451153.zip |
BeanValidator changed to throw exception with array of causes (#11324)
BeanValidator was modified to throw InvalidValueException with array of causes
instead of exception with one message including HTML. This way
AbstractErrorMessage is able to create correct error notification message with
multiple lines.
Change-Id: I414189f56ac282daad9dd3fe58d13fd99108c479
Diffstat (limited to 'server/src/com/vaadin/data')
-rw-r--r-- | server/src/com/vaadin/data/validator/BeanValidator.java | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/server/src/com/vaadin/data/validator/BeanValidator.java b/server/src/com/vaadin/data/validator/BeanValidator.java index ea7189bc5e..54efa51ac1 100644 --- a/server/src/com/vaadin/data/validator/BeanValidator.java +++ b/server/src/com/vaadin/data/validator/BeanValidator.java @@ -17,8 +17,6 @@ package com.vaadin.data.validator; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; import java.util.Locale; import java.util.Set; @@ -115,7 +113,9 @@ public class BeanValidator implements Validator { Set<?> violations = getJavaxBeanValidator().validateValue(beanClass, propertyName, value); if (violations.size() > 0) { - List<String> exceptions = new ArrayList<String>(); + InvalidValueException[] causes = new InvalidValueException[violations + .size()]; + int i = 0; for (Object v : violations) { final ConstraintViolation<?> violation = (ConstraintViolation<?>) v; String msg = getJavaxBeanValidatorFactory() @@ -123,16 +123,11 @@ public class BeanValidator implements Validator { violation.getMessageTemplate(), new SimpleContext(value, violation .getConstraintDescriptor()), locale); - exceptions.add(msg); + causes[i] = new InvalidValueException(msg); + ++i; } - StringBuilder b = new StringBuilder(); - for (int i = 0; i < exceptions.size(); i++) { - if (i != 0) { - b.append("<br/>"); - } - b.append(exceptions.get(i)); - } - throw new InvalidValueException(b.toString()); + + throw new InvalidValueException(null, causes); } } |