Search in sources :

Example 16 with ModelAndView

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;
}
Also used : HolidayDetails(org.mifos.dto.domain.HolidayDetails) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with 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;
}
Also used : UserDetailDto(org.mifos.dto.domain.UserDetailDto) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayList(java.util.ArrayList) SystemUserSearchResultsDto(org.mifos.dto.screen.SystemUserSearchResultsDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with ModelAndView

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;
}
Also used : UserSearchDto(org.mifos.dto.domain.UserSearchDto) ModelAndView(org.springframework.web.servlet.ModelAndView) SystemUserSearchResultsDto(org.mifos.dto.screen.SystemUserSearchResultsDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with ModelAndView

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;
}
Also used : StringWriter(java.io.StringWriter) ModelAndView(org.springframework.web.servlet.ModelAndView) PrintWriter(java.io.PrintWriter) StringWriter(java.io.StringWriter) Writer(java.io.Writer) PrintWriter(java.io.PrintWriter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with ModelAndView

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;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) AdminDocumentDto(org.mifos.dto.domain.AdminDocumentDto) AccountPaymentDto(org.mifos.dto.screen.AccountPaymentDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1573 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)668 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)165 ArrayList (java.util.ArrayList)139 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)84 List (java.util.List)69 IOException (java.io.IOException)60 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)60 Date (java.util.Date)57 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)49 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)47 GetMapping (org.springframework.web.bind.annotation.GetMapping)45 HandlerMethod (org.springframework.web.method.HandlerMethod)45 IPerson (org.apereo.portal.security.IPerson)43 JSONView (com.intel.mountwilson.util.JSONView)34