If you run the application now, enter some invalid values and then click on the
newsletter checkbox (use the Reset button to return the form to its initial state when
needed) you should see the following output:
In onValidate.
In onFailure.
The form was submitted!
From this we can see that the validate event was fired first, then failure, and
finally submit.
If however, we provide correct input, the output will be different:
Setting user name: John
Setting password: Smith
In onValidate.
Submit button was pressed!
In onSuccess.
The form was submitted!
Here is how all this works.
In the very beginning, as soon as we click on the Submit button, the Form component
performs an automatic single field validation of the values using the validators we
have specified. You might have noticed that if you click on the Submit button in
an empty form no event handlers are invoked at all. This is because the initial stage
of validation happens on the client side, without submitting the form to the server.
However, for client side validation to work, the components used on the page should
provide some appropriate JavaScript (those components that come with Tapestry
do provide such JavaScript), and of course JavaScript should be enabled in the
user's browser.
Pages:
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217