use of org.mifos.application.admin.servicefacade.CoaDto 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