use of org.springframework.validation.ObjectError in project head by mifos.
the class SavingsProductPreviewController method handleBusinessRuleViolation.
private void handleBusinessRuleViolation(String editFormview, SavingsProductFormBean savingsProduct, BindingResult result, ModelAndView modelAndView, String messageKey) {
ObjectError error = new ObjectError("savingsProduct", new String[] { messageKey }, new Object[] {}, "Error: Problem persisting savings product.");
result.addError(error);
configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
modelAndView.setViewName("previewSavingsProducts");
modelAndView.addObject("savingsProduct", savingsProduct);
modelAndView.addObject("editFormview", editFormview);
populateModelAndViewForPreview(savingsProduct, modelAndView);
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class LoanProductFormBeanValidator method convertLoanAmountByLastLoanJsr303ViolationsToSpringErrors.
private void convertLoanAmountByLastLoanJsr303ViolationsToSpringErrors(BindingResult result, int lastLoanRow, ByLastLoanAmountBean byLoanCycle, Set<ConstraintViolation<ByLastLoanAmountBean>> cycleViolations) {
for (ConstraintViolation<ByLastLoanAmountBean> constraintViolation : cycleViolations) {
ObjectError error = new ObjectError("loanProduct", new String[] { buildViolationMessage("loanProduct.loanAmountByLastLoanAmount", constraintViolation) }, new Object[] { lastLoanRow + 1 }, constraintViolation.getMessage());
result.addError(error);
}
if (cycleViolations.isEmpty() && !byLoanCycle.isRangeValid()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.loanAmountByLastLoanAmount.upper" }, new Object[] { lastLoanRow + 1 }, "The upper value must be greater than lower.");
result.addError(error);
}
if (cycleViolations.isEmpty() && !byLoanCycle.minIsLessThanMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.loanAmountByLastLoanAmount.max" }, new Object[] { lastLoanRow + 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.loanAmountByLastLoanAmount.theDefault" }, new Object[] { lastLoanRow + 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 convertInstallmentsByLoanCycleJsr303ViolationsToSpringErrors.
private void convertInstallmentsByLoanCycleJsr303ViolationsToSpringErrors(BindingResult result, int loanCycleRow, ByLoanCycleBean byLoanCycle, Set<ConstraintViolation<ByLoanCycleBean>> cycleViolations) {
for (ConstraintViolation<ByLoanCycleBean> constraintViolation : cycleViolations) {
ObjectError error = new ObjectError("loanProduct", new String[] { buildViolationMessage("loanProduct.installmentsByLoanCycle", constraintViolation) }, new Object[] { loanCycleRow + 1 }, constraintViolation.getMessage());
result.addError(error);
}
if (cycleViolations.isEmpty() && !byLoanCycle.minIsLessThanMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.installmentsByLoanCycle.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.installmentsByLoanCycle.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 convertInstallmentsByLastLoanJsr303ViolationsToSpringErrors.
private void convertInstallmentsByLastLoanJsr303ViolationsToSpringErrors(BindingResult result, int lastLoanRow, ByLastLoanAmountBean byLoanCycle, Set<ConstraintViolation<ByLastLoanAmountBean>> cycleViolations) {
for (ConstraintViolation<ByLastLoanAmountBean> constraintViolation : cycleViolations) {
ObjectError error = new ObjectError("loanProduct", new String[] { buildViolationMessage("loanProduct.installmentsByLastLoanAmount", constraintViolation) }, new Object[] { lastLoanRow + 1 }, constraintViolation.getMessage());
result.addError(error);
}
if (cycleViolations.isEmpty() && !byLoanCycle.isRangeValid()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.installmentsByLastLoanAmount.upper" }, new Object[] { lastLoanRow + 1 }, "The upper value must be greater than lower.");
result.addError(error);
}
if (cycleViolations.isEmpty() && !byLoanCycle.minIsLessThanMax()) {
ObjectError error = new ObjectError("loanProduct", new String[] { "Max.loanProduct.installmentsByLastLoanAmount.max" }, new Object[] { lastLoanRow + 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.installmentsByLastLoanAmount.theDefault" }, new Object[] { lastLoanRow + 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 PreviewModifyCoaController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") CoaFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView mav = new ModelAndView(REDIRECT_TO_COA_ADMIN_SCREEN);
if (StringUtils.isNotBlank(edit)) {
mav = new ModelAndView(MODIFY_COA);
mav.addObject("formBean", formBean);
mav.addObject("COAlist", coaServiceFacade.getList(null));
} else if (StringUtils.isNotBlank(cancel)) {
status.setComplete();
} else if (result.hasErrors()) {
mav = new ModelAndView(PREVIEW_MODIFY_COA);
} else {
try {
CoaDto coaDto = new CoaDto();
coaDto.setAccountId(formBean.getAccountId());
coaDto.setAccountName(formBean.getCoaName());
coaDto.setGlCodeString(formBean.getGlCode());
coaDto.setParentGlCode(formBean.getParentGlCode());
coaServiceFacade.modify(coaDto);
status.setComplete();
} catch (BusinessRuleException ex) {
ObjectError error = new ObjectError("formBean", new String[] { ex.getMessageKey() }, new Object[] {}, "default: ");
result.addError(error);
mav.setViewName(PREVIEW_MODIFY_COA);
mav.addObject("formBean", formBean);
}
}
return mav;
}
Aggregations