Prev | Current Page 200 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"


Regexp??”checks if the string value fits the specified pattern.
We can use several validators for one component. Let's see how all this
works together.
First of all, let's add another component to the Registration page template:

:


Also, add the corresponding property to the Registration page class, age, of type
double. It could be an int indeed, but I want to show that the Min and Max validators
can work with fractional numbers too. Besides, someone might decide to enter their
age as 23.4567. This will be weird, but not against the laws.
Finally, add an Errors component to the form at the Registration page, so that we
can see error messages:



??? ??? ??? ??? ??? ???
User Input Validation
[ 162 ]
Now we can test all the available validators on one page. Let's specify the validation
rules first:
1. Both User Name and Password are required. Also, they should not be
shorter than three characters and not longer than eight characters.
2. Age is required, and it should not be less than five (change this number if
you've got a prodigy in your family) and not more than 120 (as that would
probably be a mistake).


Pages:
188189190191192193194195196197198199 200 201202203204205206207208209210211212
życzenia urodzinowewierszykiszambo betonowetypy bukmacherskieTango Olsztyn