use of org.springframework.validation.ObjectError in project head by mifos.
the class NewFundPreviewController 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") FundFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
if (StringUtils.isNotBlank(edit)) {
mav = new ModelAndView("editFunds");
mav.addObject("formBean", formBean);
mav.addObject("previewView", "newFundPreview");
} else if (StringUtils.isNotBlank(cancel)) {
mav = new ModelAndView(REDIRECT_TO_VIEW_FUNDS);
status.setComplete();
} else if (result.hasErrors()) {
mav = new ModelAndView("newFundPreview");
} else {
FundCodeDto codeDto = new FundCodeDto();
codeDto.setId(formBean.getCodeId());
codeDto.setValue(formBean.getCodeValue());
FundDto fundDto = new FundDto();
fundDto.setCode(codeDto);
fundDto.setId(formBean.getId());
fundDto.setName(formBean.getName());
try {
this.fundServiceFacade.createFund(fundDto);
status.setComplete();
} catch (BusinessRuleException e) {
ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
result.addError(error);
mav.setViewName("newFundPreview");
mav.addObject("formBean", formBean);
}
}
return mav;
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class PreviewCoaController 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) {
String viewName = REDIRECT_TO_COA_ADMIN_SCREEN;
ModelAndView modelAndView = new ModelAndView();
if (StringUtils.isNotBlank(edit)) {
viewName = DEFINE_NEW_COA;
modelAndView.setViewName(viewName);
modelAndView.addObject("formBean", formBean);
} else if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName(REDIRECT_TO_COA_ADMIN_SCREEN);
status.setComplete();
} else if (result.hasErrors()) {
modelAndView.setViewName(PREVIEW_COA);
} else {
try {
CoaDto coaDto = new CoaDto();
coaDto.setAccountName(formBean.getCoaName());
coaDto.setGlCodeString(formBean.getGlCode());
coaDto.setParentId(formBean.getParentId());
coaServiceFacade.create(coaDto);
viewName = REDIRECT_TO_COA_ADMIN_SCREEN;
modelAndView.setViewName(viewName);
status.setComplete();
} catch (BusinessRuleException e) {
ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
result.addError(error);
modelAndView.setViewName(PREVIEW_COA);
modelAndView.addObject("formBean", formBean);
}
}
return modelAndView;
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class ProductCategoryPreviewController 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") ProductCategoryFormBean formBean, BindingResult result) {
String viewName = REDIRECT_TO_ADMIN_SCREEN;
ModelAndView modelAndView = new ModelAndView();
if (StringUtils.isNotBlank(edit)) {
viewName = "editCategoryInformation";
modelAndView.setViewName(viewName);
modelAndView.addObject("formBean", formBean);
modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewproductcategories", "viewProductCategories.ftl").withLink(formBean.getProductCategoryName(), "").build());
} else if (StringUtils.isNotBlank(cancel)) {
viewName = REDIRECT_TO_ADMIN_SCREEN;
modelAndView.setViewName(viewName);
} else if (result.hasErrors()) {
viewName = "categoryPreview";
modelAndView.setViewName(viewName);
modelAndView.addObject("formBean", formBean);
modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewproductcategories", "viewProductCategories.ftl").withLink(formBean.getProductCategoryName(), "").build());
} else {
Integer productStatusId = Integer.parseInt(formBean.getProductCategoryStatusId());
Integer productTypeId = Integer.parseInt(formBean.getProductTypeId());
CreateOrUpdateProductCategory productCategory = new CreateOrUpdateProductCategory(productTypeId.shortValue(), formBean.getProductCategoryName(), formBean.getProductCategoryDesc(), productStatusId.shortValue(), formBean.getGlobalPrdCategoryNum());
try {
this.adminServiceFacade.updateProductCategory(productCategory);
modelAndView.setViewName(REDIRECT_TO_ADMIN_SCREEN);
} catch (BusinessRuleException e) {
ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
result.addError(error);
modelAndView.setViewName("categoryPreview");
modelAndView.addObject("formBean", formBean);
modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewproductcategories", "viewProductCategories.ftl").withLink(formBean.getProductCategoryName(), "").build());
}
}
return modelAndView;
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class SavingsProductValidator method validateGroup.
public void validateGroup(SavingsProductFormBean savingsProductFormBean, BindingResult result) {
if (savingsProductFormBean.isGroupSavingAccount() && StringUtils.isBlank(savingsProductFormBean.getSelectedGroupSavingsApproach())) {
ObjectError error = new ObjectError("savingsProduct", new String[] { "NotEmpty.savingsProduct.selectedGroupSavingsApproach" }, new Object[] {}, "default: ");
result.addError(error);
}
}
use of org.springframework.validation.ObjectError in project head by mifos.
the class SavingsProductValidator method validateManadtorySavingsProduct.
public void validateManadtorySavingsProduct(SavingsProductFormBean savingsProductFormBean, BindingResult result) {
if (savingsProductFormBean.isMandatory() && savingsProductFormBean.getAmountForDeposit() == null || savingsProductFormBean.getAmountForDeposit().intValue() <= 0) {
ObjectError error = new ObjectError("savingsProduct", new String[] { "Min.savingsProduct.amountForDesposit" }, new Object[] {}, "default: ");
result.addError(error);
}
}
Aggregations