If this first stage of validation was successful, the Form component sends the values
provided by the user to the server, so they can be set to the appropriate properties of
the page class. This is why we saw the following lines of output:
Setting user name: John
Setting password: Smith
If however the first stage revealed a problem, the values submitted by the user are not
set to the properties of the page class, and none of the event handlers get invoked.
Chapter 6
[ 169 ]
On the next step, the Form component fires the validate event, and Tapestry
invokes our onValidate method. This is where we should put any custom validation
logic, additional to that performed automatically by the form on single fields. If our
additional logic defines a problem, we can record a validation error with a message
of our choice. This is what we'll be doing in the next section.
After the onValidate method does its job, Tapestry checks if there are any errors
recorded in ValidationTracker??”either automatically or by ourselves. If there
are, then the failure event is generated and the onFailure method is invoked,
otherwise the success event is fired and the onSuccess method runs. Finally, the
submit event is generated, and so the onSubmit method runs no matter what.
Pages:
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218