How to validate a modal form? Strange behavior!

I have a form inside a modal window. A OK button validates the form with the following code:

      try {
        form.validate();
      } catch (Exception ex) {
        return;
      }
      // otherwise process form content

I would expect that if something is invalid an exception would be raised (and shown in component error) and then return upon exception catching. But, for some strange reason this does not happen. So I tried to debug what is going on. I am using Netbeans in a Maven Project (maybe wrong decision, I’ll try Eclipse), and I am unable to trace execution inside Vaadin code. So I tried to insert some statements to understand what was going on. My guess was propertyIds was empty for some reason, so I inserted an extra line to show visible properties:

      try {
       [b]

form.getVisibleItemProperties().size();
[/b]
form.validate();
} catch (Exception ex) {
return;
}

Now validation is performed, but if I remove the line validation does not work. Any idea of what I am doing wrong?

How do you know a validation is performed? You mean that actually calls form.validate() or that an exception occurs? I guess the latter, which means that form.getVisibleItemProperties() returns null and you try to call size() for that and execution continues in the catch block because of NullPointerException.

Thanks Johannes,

You are absolutely right! I supposed the form was validated cause I was able to see the error messages, but what actually happens is that validation is called before, probably when the OK button is hit cause of “commit” method name). In the mean time I was able to activate source debugging on Vaadin code so I shall be able to understand better what is going on.

Once again thank you very much!

franco