protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors)
throws Exception {
AccountForm accountForm = (AccountForm) command;
Account account = accountForm.getAccount();
if (request.getParameter("account.listOption") == null) {
account.setListOption(false);
}
if (request.getParameter("account.bannerOption") == null) {
account.setBannerOption(false);
}
errors.setNestedPath("account");
getValidator().validate(account, errors);
errors.setNestedPath("");
if (accountForm.isNewAccount()) {
account.setStatus("OK");
ValidationUtils.rejectIfEmpty(errors, "account.username", "USER_ID_REQUIRED", "User ID is required.");
if (account.getPassword() == null || account.getPassword().length() < 1 ||
!account.getPassword().equals(accountForm.getRepeatedPassword())) {
errors.reject("PASSWORD_MISMATCH",
"Passwords did not match or were not provided. Matching passwords are required.");
}
}
else if (account.getPassword() != null && account.getPassword().length() > 0) {
if (!account.getPassword().equals(accountForm.getRepeatedPassword())) {
errors.reject("PASSWORD_MISMATCH",
"Passwords did not match. Matching passwords are required.");
}
}
}