Prev | Current Page 201 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"


3. Email address is not required, but if entered, should match a common
pattern.
Here are the changes to the Registration page template that will implement the
specified validation rules:

t:validate="required,minlength=3,maxlength=8"/>

??¦

t:validate="required,minlength=3,maxlength=8"/>

...

t:validate="required,min=5,max=120"/>

...
t:validate="regexp"/>
As you see, it is very easy to pass a parameter to a validator, like min=5 or
maxlength=8. But, where do we specify a pattern for the Regexp validator?
The answer is, in the message catalog. Let's add the following line to the
app.properties file:
email-regexp=^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)
+([a-zA-Z0-9]{2,4})+$
Chapter 6
[ 163 ]
This will serve as a regular expression for all Regexp validators applied to
components with ID email throughout the application. In the next chapter you will
see how to create page-specific message catalogs.
Run the application, go to the Registration page and, try to submit the empty form.


Pages:
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
parking pyrzowice Prince Lion wynajem rusztowań hosting ranking przeglądarek