Identify the field that is erroneous and mark it in some way. If possible, display the erroneous value, and maybe even explain why exactly it is wrong. Let's see how Tapestry 5, being a highly efficient and user-friendly framework, handles these issues. Adding Validation to Components Have a look at the Start page of the running Celebrity Collector. There is a login form that expects the user to enter some values into its two fields. But, what if the user didn't enter anything and still clicked on the Log In button? Currently, the application will decide that the credentials are wrong and the user will be redirected to the Registration page, and receive an invitation to register. This logic does make some sense; but, it isn't the best line of action, as the button might have been pressed by mistake. ??? ??? ??? User Input Validation [ 158 ] These two fields, User Name and Password, are actually mandatory, and if no value was entered into them, then it should be considered an error. All we need to do for this is to add a required validator to every field, as seen in the following code:
Label for the first text box:
t:label="User Name" t:validate="required"/>
The second label:
t:type="PasswordField" t:validate="required"/>
Just one additional attribute for each component, and let's see how this works now.