onValidateFromForm()
On Sun, Apr 17, 2011 at 8:05 AM, Igor Drobiazko <[email protected]> wrote: > 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 > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
