use of org.springframework.validation.ObjectError in project head by mifos.
the class LoanProductFormBeanValidator method convertInstallmentsSameForAllLoansJsr303ViolationsToSpringErrors.
private void convertInstallmentsSameForAllLoansJsr303ViolationsToSpringErrors(BindingResult result, SameForAllLoanBean sameForAllLoanBean, Set<ConstraintViolation<SameForAllLoanBean>> violations) {
for (ConstraintViolation<SameForAllLoanBean> constraintViolation : violations) {
ObjectError error = new ObjectError("loanProduct", new String[] { buildViolationMessage("loanProduct.installmentsSameForAllLoans", constraintViolation) }, new Object[] {}, constraintViolation.getMessage());
result.addError(error);
}
if (violations.isEmpty() && !sameForAllLoanBean.minIsLessThanMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.installmentsSameForAllLoans.max" }, new Object[] {}, "The min must be less than max.");
result.addError(error);
}
if (violations.isEmpty() && !sameForAllLoanBean.defaultIsBetweenMinAndMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.installmentsSameForAllLoans.theDefault" }, new Object[] {}, "The default is not within min and max range.");
result.addError(error);
}
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class LoanProductFormBeanValidator method convertLoanAmountByLoanCycleJsr303ViolationsToSpringErrors.
private void convertLoanAmountByLoanCycleJsr303ViolationsToSpringErrors(BindingResult result, int loanCycleRow, ByLoanCycleBean byLoanCycle, Set<ConstraintViolation<ByLoanCycleBean>> cycleViolations) {
for (ConstraintViolation<ByLoanCycleBean> constraintViolation : cycleViolations) {
ObjectError error = new ObjectError("loanProduct", new String[] { buildViolationMessage("loanProduct.loanAmountByLoanCycle", constraintViolation) }, new Object[] { loanCycleRow + 1 }, constraintViolation.getMessage());
result.addError(error);
}
if (cycleViolations.isEmpty() && !byLoanCycle.minIsLessThanMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.loanAmountByLoanCycle.max" }, new Object[] { loanCycleRow + 1 }, "The min must be less than max.");
result.addError(error);
}
if (cycleViolations.isEmpty() && !byLoanCycle.defaultIsBetweenMinAndMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.loanAmountByLoanCycle.theDefault" }, new Object[] { loanCycleRow + 1 }, "The default is not within min and max range.");
result.addError(error);
}
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class LoanProductFormBeanValidator method validateInterestRateRange.
private void validateInterestRateRange(LoanProductFormBean loanProductFormBean, BindingResult result) {
if (!result.hasErrors()) {
if (loanProductFormBean.getMinInterestRate() > loanProductFormBean.getMaxInterestRate()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Range.loanProduct.maxInterestRate" }, new Object[] {}, "The min must be less than max.");
result.addError(error);
}
if (loanProductFormBean.getDefaultInterestRate() < loanProductFormBean.getMinInterestRate() || loanProductFormBean.getDefaultInterestRate() > loanProductFormBean.getMaxInterestRate()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Range.loanProduct.defaultInterestRate" }, new Object[] {}, "The min must be less than max.");
result.addError(error);
}
}
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class LoanProductFormBeanValidator method convertLoanAmountSameForAllLoansJsr303ViolationsToSpringErrors.
private void convertLoanAmountSameForAllLoansJsr303ViolationsToSpringErrors(BindingResult result, SameForAllLoanBean sameForAllLoanBean, Set<ConstraintViolation<SameForAllLoanBean>> violations) {
for (ConstraintViolation<SameForAllLoanBean> constraintViolation : violations) {
ObjectError error = new ObjectError("loanProduct", new String[] { buildViolationMessage("loanProduct.sameForAllLoans", constraintViolation) }, new Object[] {}, constraintViolation.getMessage());
result.addError(error);
}
if (violations.isEmpty() && !sameForAllLoanBean.minIsLessThanMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.sameForAllLoans.max" }, new Object[] {}, "The min must be less than max.");
result.addError(error);
}
if (violations.isEmpty() && !sameForAllLoanBean.defaultIsBetweenMinAndMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.sameForAllLoans.theDefault" }, new Object[] {}, "The default is not within min and max range.");
result.addError(error);
}
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class ChangePasswordController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public String processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") @Valid ChangePasswordFormBean formBean, BindingResult result, SessionStatus status, HttpServletRequest request) {
String viewName = HOME_PAGE;
if (CANCEL_PARAM_VALUE.equals(cancel)) {
viewName = REDIRECT_AND_LOGOUT;
status.setComplete();
} else if (result.hasErrors()) {
viewName = "changePassword";
} else {
try {
ChangePasswordRequest changePasswordRequest = new ChangePasswordRequest(formBean.getUsername(), formBean.getOldPassword(), formBean.getNewPassword());
loginServiceFacade.changePassword(changePasswordRequest);
status.setComplete();
} catch (BusinessRuleException e) {
ObjectError error = new ObjectError("passwordUsed", messageSource.getMessage("error.passwordAlreadyUsedException", null, RequestContextUtils.getLocale(request)));
result.addError(error);
viewName = "changePassword";
}
}
return viewName;
}
Aggregations