use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class DefineProductCategoryPreviewController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @RequestParam(value = EDIT_PARAM, required = false) String edit, @ModelAttribute("formBean") ProductCategoryFormBean bean, BindingResult result) {
ModelAndView modelAndView = new ModelAndView("defineNewCategory");
if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName(REDIRECT_TO_ADMIN);
} else if (StringUtils.isNotBlank(edit)) {
modelAndView.setViewName("defineNewCategory");
modelAndView.addObject("formBean", bean);
modelAndView.addObject("typeList", this.getProductCategoryTypes());
} else if (result.hasErrors()) {
modelAndView.setViewName("newProductCategoryPreview");
modelAndView.addObject("formBean", bean);
} else {
CreateOrUpdateProductCategory productCategory = new CreateOrUpdateProductCategory(Short.parseShort(bean.getProductTypeId()), bean.getProductCategoryName(), bean.getProductCategoryDesc(), Short.parseShort(bean.getProductCategoryStatusId()), bean.getGlobalPrdCategoryNum());
try {
this.adminServiceFacade.createProductCategory(productCategory);
modelAndView.setViewName(REDIRECT_TO_ADMIN);
} catch (BusinessRuleException e) {
ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
result.addError(error);
modelAndView.setViewName("newProductCategoryPreview");
modelAndView.addObject("formBean", bean);
}
}
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class DefineProductCategoryPreviewController method showPopulatedForm.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView showPopulatedForm(ProductCategoryFormBean formBean) {
ModelAndView modelAndView = new ModelAndView("defineNewCategory");
modelAndView.addObject("formbean", formBean);
modelAndView.addObject("typeList", this.getProductCategoryTypes());
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class DefineProductMixController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String canceBtn, @RequestParam(value = PREVIEW_PARAM, required = false) String previewBtn, @ModelAttribute("formBean") ProductMixFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView mav = new ModelAndView("defineProductMix");
ProductMixFormValidator formValidator = new ProductMixFormValidator();
if (StringUtils.isNotBlank(canceBtn)) {
mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
status.setComplete();
}
if (StringUtils.isBlank(formBean.getProductTypeId())) {
List<ProductTypeDto> productTypes = this.adminServiceFacade.retrieveProductTypesApplicableToProductMix();
mav.addObject("formBean", productMixAssembler.createFormBean(productTypes));
validateForPreview(formValidator, formBean, result, previewBtn);
} else if (StringUtils.isNotBlank(formBean.getProductTypeId()) && StringUtils.isBlank(formBean.getProductId())) {
populateProductNameOptions(formBean);
validateForPreview(formValidator, formBean, result, previewBtn);
} else if (StringUtils.isNotBlank(formBean.getProductTypeId()) && StringUtils.isNotBlank(formBean.getProductId()) && (formBean.getAllowed() == null && formBean.getNotAllowed() == null)) {
populateAllowedNotAllowedOptions(formBean);
validateForPreview(formValidator, formBean, result, previewBtn);
} else {
checkAndFixFormStringArrys(formBean);
validateForPreview(formValidator, formBean, result, previewBtn);
ProductMixPreviewDto preview = this.productMixAssembler.createProductMixPreview(formBean);
mav = new ModelAndView("previewProductMix");
mav.addObject("ref", preview);
mav.addObject("formView", "defineProductMix");
}
return mav;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class DeleteCoaController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String cancel, @Valid @ModelAttribute("formBean") CoaFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView mav = new ModelAndView(REDIRECT_TO_COA_ADMIN_SCREEN);
if (StringUtils.isNotBlank(cancel)) {
status.setComplete();
} else {
try {
coaServiceFacade.delete(formBean.getAccountId());
status.setComplete();
} catch (BusinessRuleException ex) {
ObjectError error = new ObjectError("formBean", new String[] { ex.getMessageKey() }, new Object[] {}, "default: ");
result.addError(error);
mav.setViewName(DELETE_COA);
mav.addObject("formBean", formBean);
}
}
return mav;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class DateTimeUpdateController method handleRequestInternal.
@Override
@RequestMapping("/dateTimeUpdate.ftl")
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
ModelAndView returnValue = new ModelAndView("pageNotFound");
if (TestMode.MAIN == getTestingService().getTestMode()) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
} else {
String dateTimeString = request.getParameter("dateTime");
String result = null;
if (null == dateTimeString) {
result = "Missing 'dateTime' parameter!";
} else if ("system".equals(dateTimeString)) {
getDateTimeService().resetToCurrentSystemDateTime();
result = getDateTimeService().getCurrentDateTime().toString();
} else {
DateTimeFormatter formatter = ISODateTimeFormat.basicDateTimeNoMillis();
DateTime dateTime = formatter.parseDateTime(dateTimeString);
getDateTimeService().setCurrentDateTime(dateTime);
result = dateTime.toString();
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("updateResult", result);
model.put("request", request);
Map<String, Object> status = new HashMap<String, Object>();
List<String> errorMessages = new ArrayList<String>();
status.put("errorMessages", errorMessages);
ModelAndView modelAndView = new ModelAndView("dateTimeUpdate", "model", model);
modelAndView.addObject("status", status);
returnValue = modelAndView;
}
return returnValue;
}
Aggregations