Search in sources :

Example 6 with CoaDto

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;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ObjectError(org.springframework.validation.ObjectError) CoaDto(org.mifos.application.admin.servicefacade.CoaDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CoaDto (org.mifos.application.admin.servicefacade.CoaDto)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ModelAndView (org.springframework.web.servlet.ModelAndView)3 BusinessRuleException (org.mifos.service.BusinessRuleException)2 ObjectError (org.springframework.validation.ObjectError)2 ArrayList (java.util.ArrayList)1 COABO (org.mifos.accounts.financial.business.COABO)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1