use of org.springframework.web.servlet.ModelAndView 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.web.servlet.ModelAndView in project head by mifos.
the class NewOfficePreviewController method processSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @RequestParam(value = EDIT_PARAM, required = false) String edit, @ModelAttribute("officeFormBean") OfficeFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
if (StringUtils.isNotBlank(cancel)) {
status.setComplete();
} else if (result.hasErrors()) {
modelAndView = new ModelAndView("previewOfficeDetails");
modelAndView.addObject("officeFormBean", formBean);
modelAndView.addObject("showError", "true");
} else if (StringUtils.isNotBlank(edit)) {
EditOfficeInformationController editOfficeInformationController = new EditOfficeInformationController(officeServiceFacade);
modelAndView = new ModelAndView("defineNewOffice");
modelAndView.addObject("showError", "false");
if (!formBean.getLevelId().equals("1")) {
modelAndView.addObject("parentOffices", editOfficeInformationController.getParentDetails(formBean.getLevelId()));
}
modelAndView.addObject("officeTypes", editOfficeInformationController.getOfficeTypes(formBean.getLevelId()));
modelAndView.addObject("officeFormBean", formBean);
modelAndView.addObject("view", "enable");
}
/*Code for update office in else -vishnu*/
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class NewPenaltyPreviewController 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") PenaltyFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView modelAndView = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
AccountingConfigurationDto configurationDto = this.configurationServiceFacade.getAccountingConfiguration();
modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode());
if (StringUtils.isNotBlank(edit)) {
modelAndView.setViewName("defineNewPenalty");
modelAndView.addObject("formBean", formBean);
modelAndView.addObject("param", this.penaltyServiceFacade.getPenaltyParameters());
} else if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName(REDIRECT_TO_VIEW_PENALTIES);
status.setComplete();
} else if (result.hasErrors()) {
modelAndView.setViewName("newPenaltyPreview");
} else {
boolean ratePenalty = StringUtils.isBlank(formBean.getAmount());
Short currencyId = null;
Double rate = null;
Short penaltyFormula = null;
Short periodId = 3;
Integer duration = null;
if (ratePenalty) {
rate = Double.valueOf(formBean.getRate());
penaltyFormula = Short.valueOf(formBean.getFormulaId());
}
if (StringUtils.isNotBlank(formBean.getDuration())) {
duration = Integer.valueOf(formBean.getDuration());
}
if (StringUtils.isNotBlank(formBean.getCurrencyId())) {
currencyId = Short.valueOf(formBean.getCurrencyId());
}
if (StringUtils.isNotBlank(formBean.getPeriodTypeId())) {
periodId = Short.valueOf(formBean.getPeriodTypeId());
}
PenaltyFormDto dto = new PenaltyFormDto();
dto.setCategoryType(Short.valueOf(formBean.getCategoryTypeId()));
dto.setPenaltyPeriod(periodId);
dto.setPenaltyFrequency(Short.valueOf(formBean.getFrequencyId()));
dto.setGlCode(Short.valueOf(formBean.getGlCodeId()));
dto.setPenaltyFormula(penaltyFormula);
dto.setPenaltyName(formBean.getName());
dto.setRatePenalty(ratePenalty);
dto.setCurrencyId(currencyId);
dto.setRate(rate);
dto.setAmount(formBean.getAmount());
dto.setDuration(duration);
dto.setMin(Double.valueOf(formBean.getMin()));
dto.setMax(Double.valueOf(formBean.getMax()));
this.penaltyServiceFacade.createPenalty(dto);
status.setComplete();
}
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class PenaltyController method showAllPenalties.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showAllPenalties() {
ModelAndView modelAndView = new ModelAndView("viewPenalties");
modelAndView.addObject("savingPenalties", penaltyServiceFacade.getSavingPenalties());
modelAndView.addObject("loanPenalties", penaltyServiceFacade.getLoanPenalties());
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView 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;
}
Aggregations