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 210 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

authenticate(userName, password);
if (authenticatedUser != null)
{
user = authenticatedUser;
}
else
{
loginForm.recordError(
messages.get("authentication-failed"));
}
}
Of course, you will need to remove the listener for the submit event that was used
on this page before. Also, some appropriate error message should be added to the
message catalog:
authentication-failed=We couldn't authenticate you.
Try again or register.
Run the application and try to log in using wrong credentials. You should see
something similar to this:
Chapter 6
[ 173 ]
So far, we've successfully managed different cases of validation by dealing directly
with components in the form, or by recording errors directly to the Form component;
but, how about validation in BeanEditForm? This sophisticated component does so
much for us automatically that it doesn't make sense to use many of the skills we've
just learned.
BeanEditForm Validation
Let's say that when we are adding a new celebrity to our collection the first name
should be mandatory. This can be easily achieved by adding a @Validate annotation
to either getter or setter method of the Celebrity class, like this:
@Validate("required")
public String getFirstName()
{
return firstName;
}
If you try to add a celebrity without specifying a first name, you will see an
appropriate error message, as the Errors component is already incorporated into
the BeanEditForm.


Pages:
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6