You can also specify a custom error message if you do not like the default one. Try
something like this:
firstName-required-message=You cannot have a celebrity without a name!
And of course you combine different validators like we did before.
Summary
Here is what we have learned in this chapter:
Tapestry 5 comes with a powerful framework for user input validation. To
use it, we have to do very little, while Tapestry does a lot for us??”applies
validators, decorates fields in error, and displays error messages.
We can provide custom error messages and Regexp patterns using message
catalogs. Although this wasn't explained in the chapter, you can also change
the styles used to display errors by overriding them in your stylesheet.
Tapestry 5 comes with five validators that will cover most needs. You can
combine several of them to achieve the desired result.
???
???
???
User Input Validation
[ 174 ]
You can provide custom validation, for example cross-form validation, in the
validate event handler.
To validate the fields of BeanEditForm, the @Validate annotation should
be used on either the getter or setter method of the validated property in the
edited class.
You have already seen that it is possible to have both application-wide and pagespecific
message catalogs, and the next chapter will explain how exactly this can be
done.
Pages:
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223