SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 207 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"


From this logic, we can make an inference that the proper place for any code that
should run only in case of successful validation is the onSuccess method, and so we
need to change the code of the Registration class like this:
void onSubmit()
{
System.out.println("The form was submitted!");
}
String onSuccess()
{
System.out.println("In onSuccess.");
if (unsubscribe) subscribe = false;
return nextPage;
}
Another conclusion is that if we want to perform any additional validation, this
should be done in the onValidate method.
Cross-Form Validation
We do need to perform custom validation in a couple of places. First of all, at the
Registration page we should check whether the two versions of password are
identical, and if not, we should report a problem.
To begin with, we need to have a reference to the Form component to record any
eventual error in the page class code, and it is very easy to get:
@Component
private Form registrationForm;
Here the name of the private class member is the same as the ID of the Form
component, so we do not need to clarify exactly which form we mean here.
User Input Validation
[ 170 ]
We can record an error in the form in two ways??”specifying the component which
is in error and without mentioning any components.


Pages:
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
darmowe mp3 Beton Inowrocław pożyczka pko bp dieta w cukrzycy moto