use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class PreviewHolidayController 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") HolidayFormBean formBean, BindingResult result, SessionStatus status) {
String viewName = REDIRECT_TO_ADMIN_SCREEN;
ModelAndView modelAndView = new ModelAndView();
if (StringUtils.isNotBlank(edit)) {
viewName = "defineNewHoliday";
modelAndView.setViewName(viewName);
modelAndView.addObject("formBean", formBean);
} else if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName("redirect:viewHolidays.ftl");
status.setComplete();
} else if (result.hasErrors()) {
modelAndView.setViewName("previewHoliday");
} else {
HolidayDetails holidayDetail = holidayAssembler.translateHolidayFormBeanToDto(formBean);
List<Short> branchIds = holidayAssembler.convertToIds(formBean.getSelectedOfficeIds());
this.holidayServiceFacade.createHoliday(holidayDetail, branchIds);
viewName = REDIRECT_TO_ADMIN_SCREEN;
modelAndView.setViewName(viewName);
status.setComplete();
}
return modelAndView;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class SystemUserSearchController method displaySystemUsers.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView displaySystemUsers(ModelMap model) {
ModelAndView mav = new ModelAndView("viewSystemUsers");
SystemUserSearchFormBean formBean = (SystemUserSearchFormBean) model.get("searchResults");
SystemUserSearchResultsDto result = (SystemUserSearchResultsDto) model.get("pagedResults");
if (result == null) {
List<UserDetailDto> pagedUserDetails = new ArrayList<UserDetailDto>();
result = new SystemUserSearchResultsDto(0, 0, 0, 0, pagedUserDetails);
formBean = new SystemUserSearchFormBean();
}
mav.addObject("searchResults", formBean);
mav.addObject("pagedResults", result);
return mav;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class SystemUserSearchController method processSearch.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSearch(@RequestParam(required = false, value = "next") String next, @RequestParam(required = false, value = "previous") String previous, @RequestParam(required = false, value = "searchbutton") String newSearch, @RequestParam(required = false, value = "lastSearch") String lastSearchTerm, @RequestParam(required = true, value = "lastPage") Integer lastPage, @ModelAttribute("searchResults") SystemUserSearchFormBean searchResultsFormBean) {
int startingPage = lastPage;
if (StringUtils.isNotBlank(next)) {
startingPage++;
searchResultsFormBean.setSearch(lastSearchTerm);
} else if (StringUtils.isNotBlank(previous)) {
startingPage--;
searchResultsFormBean.setSearch(lastSearchTerm);
} else if (StringUtils.isNotBlank(newSearch)) {
startingPage = 1;
}
if (startingPage <= 0) {
startingPage = 1;
}
UserSearchDto searchDto = new UserSearchDto(searchResultsFormBean.getSearch(), startingPage, 10);
SystemUserSearchResultsDto dto = this.personnelServiceFacade.searchUser(searchDto);
ModelAndView mav = new ModelAndView("redirect:/viewSystemUsers.ftl");
mav.addObject("searchResults", searchResultsFormBean);
mav.addObject("pagedResults", dto);
return mav;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class UncaughtExceptionController method handleException.
@RequestMapping("/uncaughtException.ftl")
public ModelAndView handleException(HttpServletRequest request) {
// http://java.sun.com/developer/technicalArticles/Servlets/servletapi2.3
Object obj = request.getAttribute("javax.servlet.error.exception");
Throwable cause = null;
if (obj != null) {
cause = (Throwable) obj;
}
String requestUri = request.getRequestURI();
logger.error("Uncaught exception while accessing '" + requestUri + "'", cause);
ModelAndView mm = new ModelAndView();
mm.setViewName("uncaughtException");
mm.addObject("uncaughtException", cause);
mm.addObject("requestUri", requestUri);
if (cause != null) {
Writer result = new StringWriter();
cause.printStackTrace(new PrintWriter(result));
mm.addObject("stackString", result.toString());
}
return mm;
}
use of org.springframework.web.servlet.ModelAndView in project head by mifos.
the class ViewCustomerDetailsController method showLastPaymentReceipt.
@RequestMapping(value = "/printClientPaymentReceipt", method = RequestMethod.GET)
public ModelAndView showLastPaymentReceipt(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String globalAccountNum) {
ModelAndView modelAndView = new ModelAndView("printClientPaymentReceipt");
String gan = null;
if (globalAccountNum == null) {
gan = request.getSession().getAttribute("globalAccountNum").toString();
} else {
gan = globalAccountNum;
}
String clientSystemId = request.getParameter("globalCustNum");
AccountPaymentDto clientAccountPayment = clientServiceFacade.getClientAccountPayments(gan).get(0);
List<AdminDocumentDto> adminDocuments = adminDocumentsServiceFacade.getAdminDocumentsForAccountPayment(clientAccountPayment.getPaymentId());
if (adminDocuments != null && !adminDocuments.isEmpty()) {
clientAccountPayment.setAdminDocuments(adminDocuments);
}
modelAndView.addObject("clientAccountPayment", clientAccountPayment);
modelAndView.addObject("globalAccountNum", gan);
modelAndView.addObject("clientSystemId", clientSystemId);
return modelAndView;
}
Aggregations