tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Drobiazko <igor.drobia...@gmail.com>
Subject Validate event collision & validation tracker
Date Sun, 17 Apr 2011 15:05:24 GMT
I just came across a problem, which is very nasty. Starting in 5.2 the Form
component's  validateForm event has been deprecated in favor of validate
event. The new event collides with the validate event fired by the
individual fields. This collision may result in a strange behavior of an
application, when a form is in error.

Let's consider a login form with two required fields. We type the username
and submit the form. The expected behavior is that Form.isValid() returns
false, because no value for password field was provided. But this is not the
case. Let's see the reason.

The following onValidate() method is called during the form submission
twice: for the first time to handle the event fired by a username TextField.
Becaue userName is not empty, Tapestry fires this event for individual
validation of the username TextField. Eben though the form is in error
(password is missing), form.isValid() returns true. So, authentication is
performed, which is wrong.

For the second time the method is called to handle the event fired by Form
component. This time the validation tracker is not empty, so the method
returns an expected result

    void onValidate() {

        if (form.isValid()) {
            User authenticated = authenticator.authenticate(userName,
password);
       }
   }

Because validate event is an replacement for validateForm, it must be
possible to check if the form is in error but in fact it is not. Now I'm
looking for the best way to fix the problem. Any ideas?

-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message