Run the application, leave both fields empty and click on the Log In button. Here is
what you should see:
Chapter 6
[ 159 ]
Both fields, including their labels, are clearly marked now as an error. We even
have some kind of graphical marker for the problematic fields. However, one thing
is missing??”a clear explanation of what exactly went wrong. To display such a
message, one more component needs to be added to the page. Modify the page
template, as done here:
The Errors component is very simple, but one important thing to remember is that
it should be placed inside of the Form component, which in turn, surrounds the
validated components. Let's run the application again and try to submit an empty
form. Now the result should look like this:
This kind of feedback doesn't leave any space for doubt, does it? Of course if you
wish, you can override the default styles, by following the instructions given in the
previous chapter for styling BeanEditForm.
User Input Validation
[ 160 ]
If you see that the error messages are strongly misplaced to the left, it
means that an error in the default.css file that comes with Tapestry
distribution still hasn't been fixed.
Pages:
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209