1 package ru
.rentdom
.pages
;
3 import org
.apache
.tapestry5
.ValidationException
;
4 import org
.apache
.tapestry5
.annotations
.Component
;
5 import org
.apache
.tapestry5
.annotations
.Property
;
6 import org
.apache
.tapestry5
.corelib
.components
.Form
;
7 import org
.apache
.tapestry5
.corelib
.components
.PasswordField
;
8 import org
.apache
.tapestry5
.hibernate
.annotations
.CommitAfter
;
9 import org
.apache
.tapestry5
.ioc
.Messages
;
10 import org
.apache
.tapestry5
.ioc
.annotations
.Inject
;
12 import ru
.rentdom
.entities
.User
;
13 import ru
.rentdom
.services
.user
.UserService
;
14 import ru
.rentdom
.services
.user
.UserService
.UserNameErrors
;
16 public class Register
{
18 private UserService userService
;
24 private String password1
;
27 private Messages messages
;
30 private Form registerForm
;
33 private PasswordField password
;
43 userService
.createUser(user
);
46 void onValidateFromUserName(String userName
) throws ValidationException
48 UserNameErrors err
= userService
.validateUserName(userName
);
49 if (err
.equals(UserNameErrors
.NO_ERRORS
))
51 throw new ValidationException(messages
.get(err
.toString()));
54 void onValidateFromEmail(String email
) throws ValidationException
56 UserNameErrors err
= userService
.validateEmail(email
);
57 if (err
.equals(UserNameErrors
.NO_ERRORS
))
59 throw new ValidationException(messages
.get(err
.toString()));
62 void onValidateFromPassword1(String password
) throws ValidationException
65 throw new ValidationException(messages
.get("empty-password"));
68 void onValidateFromPassword(String password
) throws ValidationException
71 throw new ValidationException(messages
.get("empty-password"));
76 if (password1
!=null && user
.getPassword()!=null && !password1
.equals(user
.getPassword()))
77 registerForm
.recordError(password
, messages
.get("passwords-not-mathes"));