Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Retrieving causes from InvalidValueException
Hi,
I'm trying to validate an inputform at once, without using the fieldvalidation possibilities. I'm doing this by overriding de validate() method of the form. In this method I put all the validations. For every validationerror I add an InvalidValueException to an array. Finally this array is added as causes to a new InvalidValueException which is thrown to a screen (VerticalLayout object). In the screen I want to retrieve all the InvalidValueException added in the array. How do I retrieve this InvalidValueException from the causes. As far as I can see, the causes are a final field in the without any possibilities to retrieve it.
My code on the form is:
public void validate() throws InvalidValueException {
super.validate();
InvalidValueException[] failureException = new InvalidValueException[100];
ArrayList<InvalidValueException> failures = new ArrayList<InvalidValueException>();
// validate mandatory fields
if (StringUtils.isEmpty(getCollectionCountryCode())){
failures.add(new InvalidValueException("Collection country code is empty"));
}
if (StringUtils.isEmpty(getCollectionProvince()) && StringUtils.isEmpty(getCollectionLocation())){
failures.add(new InvalidValueException("Either province or location should be entered"));
}
if (!failures.isEmpty()){
throw new InvalidValueException("Messages: ", failures.toArray((InvalidValueException[]) failureException));
}
}
I want to retrieve the object in "failures". Any suggestions are welcome.
Thanks in advance,
Jolanda
Hi, you should try out a 6.4 nightly. InvalidValueException.getCauses() was added there some time ago (http://dev.vaadin.com/ticket/2228).